帮我美化hwndMain = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 600, 600, NULL, NULL, hInstance, NULL);窗口的创建
时间: 2024-02-10 18:15:50 浏览: 89
好的,以下是美化后的代码:
```c++
HWND hwndMain = CreateWindow(szWindowClass, szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
600, 600,
NULL, NULL, hInstance, NULL);
if (hwndMain == NULL) {
MessageBox(NULL, "Window creation failed!", "Error", MB_ICONERROR | MB_OK);
return 0;
}
// 设置窗口背景色为白色
HBRUSH hBrush = CreateSolidBrush(RGB(255, 255, 255));
SetClassLongPtr(hwndMain, GCLP_HBRBACKGROUND, (LONG_PTR)hBrush);
// 设置窗口图标
HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
SendMessage(hwndMain, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SendMessage(hwndMain, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
// 显示窗口
ShowWindow(hwndMain, nCmdShow);
UpdateWindow(hwndMain);
```
以上代码实现了以下功能:
1. 设置窗口背景色为白色。
2. 设置窗口图标。
3. 显示窗口并更新窗口。
阅读全文