1、编写WinMain函数
WinMain函数原型声明:
int WINAPI WinMain(HINSTANCE hlnstance, HINSTANCE hPrelnstance, LPSTR lpCmdLine,int nCmdShow);
2、设计窗口类(WNDCLASS)
窗口的特征是由WNDCLASS结构体来定义的。
3、注册窗口类(RegisterClass)
注册函数的原型声明:
ATOM RegisterClass(CONST WNDCLASS *lpWndClass);
4、创建窗口(CreateWindow)
CreateWindow函数的原型声明自行参考MSDN或者Win32 API。
5、显示并更新新窗口(ShowWindow、UpdateWindow)
显示窗口函数原型声明:BOOL ShowWindow(HWND hWnd, int nCmdShow);
更新窗口函数原型声明:BOOL UpdateWindow(HWND hWnd);
6、编写消息循环(GetMessage)
消息函数原型声明:
BOOL GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
通常我们编写消息循环代码如下:
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
7、编写窗口过程函数(WindowProc)
窗口过程函数的声明:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);