实现 InitInstance 主窗口创建与显示逻辑 完成函数3
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- [x] `_tWinMain` - `src/source/Tetris.cpp`
|
- [x] `_tWinMain` - `src/source/Tetris.cpp`
|
||||||
- [x] `MyRegisterClass` - `src/source/Tetris.cpp`
|
- [x] `MyRegisterClass` - `src/source/Tetris.cpp`
|
||||||
- [ ] `InitInstance` - `src/source/Tetris.cpp`
|
- [x] `InitInstance` - `src/source/Tetris.cpp`
|
||||||
- [ ] `WndProc` - `src/source/Tetris.cpp`
|
- [ ] `WndProc` - `src/source/Tetris.cpp`
|
||||||
- [ ] `About` - `src/source/Tetris.cpp`
|
- [ ] `About` - `src/source/Tetris.cpp`
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
+27
-2
@@ -71,9 +71,34 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
|
|||||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
{
|
{
|
||||||
// TODO(作业3): 创建并显示主窗口。
|
// TODO(作业3): 创建并显示主窗口。
|
||||||
UNREFERENCED_PARAMETER(hInstance);
|
|
||||||
UNREFERENCED_PARAMETER(nCmdShow);
|
RECT rect = { 0, 0, GRID * nWidth, GRID * nHeight };
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, TRUE);
|
||||||
|
|
||||||
|
hInst = hInstance;
|
||||||
|
|
||||||
|
HWND hWnd = CreateWindow(
|
||||||
|
szWindowClass,
|
||||||
|
szTitle,
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
0,
|
||||||
|
rect.right - rect.left,
|
||||||
|
rect.bottom - rect.top,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
hInstance,
|
||||||
|
nullptr);
|
||||||
|
|
||||||
|
if (!hWnd)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(hWnd, nCmdShow);
|
||||||
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|||||||
Reference in New Issue
Block a user