First, the window
When designing a window class:
1typedefstruct_wndclass{2UINT style;//If horizontal, vertical changes are redrawn, disable close, detect double-click3WNDPROC Lpfnwndproc;//window procedure function handle4 intCbclsextra;//class Additional Memory5 intCbwndextra;//window attached memory6HANDLE hinstance;//instance handle7HANDLE Hicon;//icons8Hcursor Hcursor;//cursor9Hbrush Hbrbackground;//BrushesTenLPCTSTR Lpszmenuname;//Menu Name OneLPCTSTR lpszClassName;//Name of the window class A}wndclass
The process by which a window function is called:
1. Assign the function address to the lpfnwndproc of the window port
2. Register the window class, the system gets the address of the window procedure function that is written
3. The application obtains the message, passes the message through DispatchMessage (&MSG), invokes the window procedure function processing.
Second, WinMain
WinMain is the portal for Windows programs, including creating window classes for message loops.
1 int WINAPI WinMain (2 hinstance hinstance,// current running instance handle 3 hinstance hPrevInstance,// default NULL4 LPSTR lpcmdline,/ / command line parameter 5 int ncmdshow// window display style 6 );
An application can run multiple instances, each running an instance, and the system will be given a handle and passed to WinMain.
Third, the message
struct Tagmsg{hwnd HWND; // owning Window UINT message; // Message Flags WPARAM WPARAM; // Additional Information LPARAM lparam;dword time; // time to enter message queue Point pt; // mouse current Position } MSG;
Four, DC
DC Device Description table. When programming, either display or print, operate on the DC and map to the appropriate device.