fork download
  1. #include <Windows.h>
  2.  
  3. #define WINDOW_CLASS_NAME TEXT("Tetris")
  4.  
  5. HWND hMainWindow;
  6. HINSTANCE hInstance;
  7.  
  8. HDC hMemDC, hBlockDC;
  9. HBITMAP hMemPrev, hBlockPrev;
  10.  
  11. LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  12. {
  13. switch(msg)
  14. {
  15. case WM_CREATE:
  16. {
  17. HDC hdc = GetDC(hWnd);
  18.  
  19. hMemDC = CreateCompatibleDC(hdc);
  20. HBITMAP hBitmap = CreateCompatibleBitmap(hdc, 24 * 10, 24 * 20);
  21. hMemPrev = (HBITMAP)SelectObject(hMemDC, hBitmap);
  22.  
  23. hBlockDC = CreateCompatibleDC(hdc);
  24. hBitmap = LoadBitmap(hInstance, TEXT("BLOCKS"));
  25. hBlockPrev = (HBITMAP)SelectObject(hBlockDC, hBitmap);
  26.  
  27. //debug
  28. BitBlt(hMemDC, 0, 0, 24, 24, hBlockDC, 0, 0, SRCCOPY);
  29.  
  30. ReleaseDC(hWnd, hdc);
  31. break;
  32. }
  33. case WM_PAINT:
  34. {
  35. PAINTSTRUCT ps;
  36. HDC hdc = BeginPaint(hWnd, &ps);
  37. BitBlt(hdc, 0, 0, 24 * 10, 24 * 20, hMemDC, 0, 0, SRCCOPY);
  38. EndPaint(hWnd, &ps);
  39. break;
  40.  
  41. }
  42. case WM_DESTROY:
  43. {
  44. HBITMAP hBitmap = (HBITMAP)SelectObject(hMemDC, hMemPrev);
  45. DeleteObject(hBitmap);
  46. DeleteDC(hMemDC);
  47.  
  48. hBitmap = (HBITMAP)SelectObject(hBlockDC, hBlockPrev);
  49. DeleteObject(hBitmap);
  50. DeleteDC(hBlockDC);
  51.  
  52. PostQuitMessage(0);
  53. break;
  54. }
  55. default:
  56. return DefWindowProc(hWnd, msg, wParam, lParam);
  57.  
  58. }
  59. return 0;
  60. }
  61.  
  62. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdLine, int cmdShow)
  63. {
  64. WNDCLASSEX wc;
  65. hInstance = hInst;
  66.  
  67. wc.cbSize = sizeof(WNDCLASSEX);
  68. wc.style = CS_HREDRAW| CS_VREDRAW;
  69. wc.lpfnWndProc = (WNDPROC)WndProc;
  70. wc.cbClsExtra = 0;
  71. wc.cbWndExtra = 0;
  72. wc.hInstance = hInst;
  73. wc.hIcon = NULL;
  74. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  75. wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
  76. wc.lpszMenuName = NULL;
  77. wc.lpszClassName = WINDOW_CLASS_NAME;
  78. wc.hIconSm = NULL;
  79.  
  80. if(!RegisterClassEx(&wc)) return -1;
  81.  
  82.  
  83. RECT r;
  84. r.left = r.top = 0;
  85. r.right = 24 * 10;
  86. r.bottom = 24 * 20;
  87.  
  88. AdjustWindowRectEx(&r,WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION, false, 0);
  89.  
  90.  
  91. hMainWindow = CreateWindow(
  92. WINDOW_CLASS_NAME, TEXT("title"),
  93. WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION,
  94. CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top,
  95. NULL, NULL, hInst, NULL);
  96.  
  97. if(hMainWindow == NULL) return -1;
  98.  
  99. ShowWindow(hMainWindow, SW_SHOW);
  100.  
  101. MSG msg;
  102.  
  103. while(GetMessage(&msg, NULL, 0, 0))
  104. {
  105. TranslateMessage(&msg);
  106. DispatchMessage(&msg);
  107. }
  108.  
  109. return 0;
  110.  
  111. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: Windows.h: No such file or directory
 #include <Windows.h>
                     ^
compilation terminated.
stdout
Standard output is empty