请求高手看下代码哪不对
#include <Windows.h>//函数声明
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM Iparam);
//hInstance 实例句柄,每一个应用程序都是有一个应用程序的实例句柄(唯一的)
//IpCmdLIne 命令行的参数
//nShowCmd 用来指定窗口如何显示,最大化,还是最小化
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
{
//MessageBox(NULL, L"Hello你好Windows", L"新建窗口",MB_OK);
//1.设计窗口
WNDCLASSEX wndClass = {};
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.IpszClassName = L"myclassname";
wndClass.IpfnWndProc = WndProc;
wndClass.hInstance = hInstance;
//2.注册窗口
if (RegisterClassEx(&wndClass) == false)
{
return -1;
}
//3.创建窗口
HWND hwnd = CreateWindow(L"myclassname", L"第一个窗口", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL);
//4.显示窗口
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
//5.处理消息
MSG msg = {0};
while (msg.message!=WM_QUIT)
{
if (PeekMessage(&msg, 0, NULL, NULL, PM_REMOVE))
{
//true取得消息
TranslateMessage(&msg);
//交给wndproc处理
DispatchMessage(&msg);
}
}
//注销窗口
UnregisterClass(L"myclassname", hInstance);
return 0;
}
//用来处理窗口的时间(比如 键盘按键 鼠标时间 窗口关闭)
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM Iparam)
{
switch (message)
{
default:
return DefWindowProc(hwnd, message, wparam, Iparam);
}
return 0;
}