- os为每一个应用程序都分配一个消息队列,应用程序从消息队列里取走消息便能够知道用户的操作和程序状态的变化
- 句柄(HANDLE):资源的标识
- 窗口的创建:1.设计一个窗口类 2.注册窗口类 3.创建窗口 4.显示及更新窗口
- 层叠的窗口(WS_OVERLAPPED)即一个有标题栏和边框的窗口
- WM_PAINT:窗口发生重绘时发送该消息, 只能使用:BeginPaint(),EndPaint()
-
while(GetMessage()) { TranslateMessage(); //把WM_KEYDOWN和WM_KEYUP翻译成WM_CHAR DispatchMessage(); } LRESULT CALLBACK WndProc() {//An application can prompt the user for confirmation, prior to destroying a window, by processing the WM_CLOSE message and calling the DestroyWindow function only if the user confirms the choice. case WM_CLOSE: if(IDYES == MessageBox()) DestroyWindow(); //该函数再发送一个WM_DESTROY消息到消息队列 break; case WM_DESTROY: PostQuitMessage(); //该函数再发送一个WM_QUIT消息到消息队列,然后GetMessage()循环终止,程序结束 break; default: return DefWindowProc(); }