实现 WndProc 主窗口消息处理逻辑 完成函数4

This commit is contained in:
2026-04-23 19:29:33 +08:00
parent 787cb8222f
commit 3b1ec70c9e
4 changed files with 36 additions and 2 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
- [x] `_tWinMain` - `src/source/Tetris.cpp`
- [x] `MyRegisterClass` - `src/source/Tetris.cpp`
- [x] `InitInstance` - `src/source/Tetris.cpp`
- [ ] `WndProc` - `src/source/Tetris.cpp`
- [x] `WndProc` - `src/source/Tetris.cpp`
- [ ] `About` - `src/source/Tetris.cpp`
## 第二阶段:游戏区域与状态初始化
Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+34
View File
@@ -104,7 +104,41 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO(作业4): 补全主窗口消息处理函数。
switch (message)
{
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
TDrawScreen(hdc, hWnd);
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)