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. int dx = 5;
  63.  
  64. switch (msg) {
  65. case WM_DESTROY:
  66. PostQuitMessage(0);
  67. break;
  68. case WM_CREATE:
  69. SetTimer(hWnd, 1, 1, NULL);
  70. break;
  71. case WM_TIMER:
  72. GetClientRect(hWnd, &rctDimension);
  73. if (x + 50 >= rctDimension.right) { blRight = FALSE; }
  74. else if (x <= 0) { blRight = TRUE; }
  75.  
  76. if (blRight) { x += dx; }
  77. else { x -= dx; }
  78.  
  79. InvalidateRect(hWnd, NULL, TRUE);
  80. break;
  81. case WM_PAINT:
  82. hdc = BeginPaint(hWnd, &ps);
  83. SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
  84. Ellipse(hdc, x, 100, x + 50, 150);
  85. EndPaint(hWnd, &ps);
  86. break;
  87. }
  88. return DefWindowProc(hWnd, msg, wParam, lParam);
  89. }
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