/*
Six steps to implement window creation:
First step: Create the entry function WinMain
Step Two: Register window class
Part III: The function of implementing the callback function
Fourth Step: Display window
Fifth Step: Update window
Sixth step: Message loop
*/
#include "stdafx.h"
callback function
LRESULT CALLBACK WinProc (HWND hwnd,uint umsg,wparam wparam,lparam LPARAM)
{
Switch (umsg)
{
Case WM_CREATE:
{
MessageBox (NULL, "a window is about to be created!") "," Infor ", MB_OK);
}
Break
Case Wm_destroy:
{
PostQuitMessage (0);
}
Break
}
return DefWindowProc (Hwnd,umsg,wparam,lparam);
}
Create an entry function
int Apientry WinMain (
HINSTANCE HInstance,
HInstance hPrevInstance,
LPSTR lpCmdLine,
int ShowCmd
)
{
HWND hwnd=0;
MSG nmsg={0};
Register window class
Wndclass cs={0};
cs.cbclsextra=0;
cs.cbwndextra=0;
Cs.hbrbackground= (Hbrush) (color_window+2);
Cs.hcursor=null;
Cs.hicon=null;
Cs.hinstance=hinstance;
Cs.lpfnwndproc= (WNDPROC) WinProc;
Cs.lpszclassname= "Main";
Cs.lpszmenuname=null;
Cs.style=cs_vredraw|cs_hredraw;
RegisterClass (&CS);//Implement Registration window
Create window
Hwnd=createwindow ("Main", "Windows", ws_overlappedwindow,200,200,500,500,null,null,hinstance,null);
Display window
ShowWindow (hwnd,sw_show);
Update window
UpdateWindow (HWND);
Message loops
while (GetMessage (&nmsg,0,null,null))
{
TranslateMessage (&NMSG);
DispatchMessage (&NMSG);
}
return 0;
}
Specific steps for Windows window creation