实现 MyRegisterClass 窗口类注册逻辑 完成函数2

This commit is contained in:
2026-04-23 19:21:36 +08:00
parent b762332098
commit cecc694362
4 changed files with 18 additions and 3 deletions
+2 -2
View File
@@ -4,8 +4,8 @@
简要说明:完成程序入口、主窗口创建、消息循环和基础对话框处理。
- [ ] `_tWinMain` - `src/source/Tetris.cpp`
- [ ] `MyRegisterClass` - `src/source/Tetris.cpp`
- [x] `_tWinMain` - `src/source/Tetris.cpp`
- [x] `MyRegisterClass` - `src/source/Tetris.cpp`
- [ ] `InitInstance` - `src/source/Tetris.cpp`
- [ ] `WndProc` - `src/source/Tetris.cpp`
- [ ] `About` - `src/source/Tetris.cpp`
Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

+16 -1
View File
@@ -50,7 +50,22 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
{
// TODO(作业2): 注册窗口类。
UNREFERENCED_PARAMETER(hInstance);
return 0;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TETRIS));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TETRIS);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)