fork download
  1. #include <tchar.h>
  2. #include <Windows.h>
  3.  
  4. const TCHAR szWndClass[] = _T("Program343class");
  5.  
  6. LRESULT CALLBACK WndProc(
  7. HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  8.  
  9. int WINAPI WinMain(
  10. HINSTANCE hInstance,
  11. HINSTANCE hPrevInstance,
  12. PSTR lpCmdLine,
  13. int nCmdShow) {
  14. HWND hWnd;
  15. WNDCLASS wc;
  16. MSG msg;
  17. BOOL bRet;
  18.  
  19. wc.style = CS_HREDRAW | CS_VREDRAW;
  20. wc.lpfnWndProc = WndProc;
  21. wc.cbWndExtra = 0;
  22. wc.cbClsExtra = 0;
  23. wc.hInstance = hInstance;
  24. wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  25. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  26. wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  27. wc.lpszMenuName = NULL;
  28. wc.lpszClassName = szWndClass;
  29.  
  30. if (!RegisterClass(&wc)) { return -1; }
  31.  
  32. hWnd = CreateWindow(
  33. szWndClass,
  34. _T("Program343のウィンドウ"),
  35. WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  36. CW_USEDEFAULT, CW_USEDEFAULT,
  37. CW_USEDEFAULT, CW_USEDEFAULT,
  38. NULL,
  39. NULL,
  40. hInstance,
  41. NULL);
  42.  
  43. if (hWnd == NULL) { return -1; }
  44.  
  45. while (bRet = GetMessage(&msg, NULL, 0, 0)) {
  46. if (bRet == -1) { return FALSE; }
  47. TranslateMessage(&msg);
  48. DispatchMessage(&msg);
  49. }
  50.  
  51. return (int)msg.wParam;
  52. }
  53.  
  54. LRESULT CALLBACK WndProc(
  55. HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  56. HDC hdc;
  57. PAINTSTRUCT ps;
  58. RECT rctDimension;
  59.  
  60. static BOOL blRight = TRUE;
  61. static int x = 0;
  62. static BOOL blBottom = TRUE;
  63. static int y = 0;
  64. int dx = 5;
  65.  
  66. switch (msg) {
  67. case WM_DESTROY:
  68. PostQuitMessage(0);
  69. break;
  70. case WM_CREATE:
  71. SetTimer(hWnd, 1, 1, NULL);
  72. break;
  73. case WM_TIMER:
  74. GetClientRect(hWnd, &rctDimension);
  75. if (x + 50 >= rctDimension.right) { blRight = FALSE; }
  76. else if (x <= 0) { blRight = TRUE; }
  77.  
  78. if (y + 50 >= rctDimension.bottom) { blBottom = FALSE; }
  79. else if (y <= 0) { blBottom = TRUE; }
  80.  
  81. if (blRight) { x += dx; }
  82. else { x -= dx; }
  83.  
  84. if (blBottom) { y += dx; }
  85. else { y -= dx; }
  86.  
  87. InvalidateRect(hWnd, NULL, TRUE);
  88. break;
  89. case WM_PAINT:
  90. hdc = BeginPaint(hWnd, &ps);
  91. SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
  92. Ellipse(hdc, x, 100, x + 50, 150);
  93. EndPaint(hWnd, &ps);
  94. break;
  95. }
  96. return DefWindowProc(hWnd, msg, wParam, lParam);
  97. }
  98.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:10: fatal error: tchar.h: No such file or directory
 #include <tchar.h>
          ^~~~~~~~~
compilation terminated.
stdout
Standard output is empty