1, windows programming is a kind of event-driven programming techniques, mainly depending on the message. When end users want to complete a operate, you'll want to contact some sort of OS assistance, and OS user needs to deal the message, and put in to the message queue, the final application eliminated through the message queue the message and react.
2, message structure:
typedef struct tagMSG / / msg
HWND hwnd; / / Receive the message window handle. And which window is associated.
UINT message; / / message ID. What is the message itself.
WPARAM wParam; / / messages for additional information. Depending on the message itself.
LPARAM lParam;
DWORD time; / / message delivery time.
POINT pt; / / message delivery,
Windows 7 Activation, the location of the cursor on the screen.
MSG;
3, message queues:
OS every application are for it to make a message queue,
Office 2007 Professional, message queue is often a FIFO buffer, where each and every component is often a message, OS will probably be created for each message into the message queue by the purchase, the application at all times get away the present message queue the very first message, the application the user eliminated the message right after the operation and treatments state, then its response to deal with that message, the message to reply to code.
four, making use of the VC furthermore to an excellent C programming fundamentals required to grasp two:
one, the message by itself. Symbolize the unique consumer information and facts and application state.
Second, for the particular message is, allow the OS performs a certain purpose to respond to messages.
5, Window system entry:
int WINAPI WinMain (
HINSTANCE hInstance, / / handle the present case.
HINSTANCE hPrevInstance, / / previous situation manage.
LPSTR lpCmdLine,
Microsoft Office 2010, / / command-line
int nCmdShow pointer ; / / (window) reveals the state
);
Description: WinMain purpose is actually a Windows system entry level function known as through the OS once the OS starts the application when, winmain operate parameters passed by the OS.
six, to generate a total window to go by means of the following 4 actions:
Very first, the design of the window class; such as: WNDCLASS wndcls;
Second, sign up the window class; for instance: RegisterClass (& wndcls);
Third, produce a window; such as: CreateWindow (),
Microsoft Office 2010 Professional Plus, CreateWindowEX ();
Fourth,
Windows 7 Professional, display and update the window. Such as: ShowWindow (), UpdateWindow ();
Note: when creating the window ought to be depending on the registered window class.
7, Windows provides the window class:
typedef struct _WNDCLASS
UINT style; / / window type
WNDPROC lpfnWndProc; / / window procedure function pointer (callback function)
int cbCl######tra; / / window class additional bytes for the shared type of window. Usually 0.
int cbWndExtra; / / window additional bytes. Usually set to 0.
HANDLE hInstance; / / the current application instance handle.
HICON hIcon; / / icon handle LoadIcon ();
HCURSOR hCursor; / / Cursor handle LoadCursor ();
HBRUSH hbrBackground; / / brush handle (HBRUSH) GetStockObject ();
LPCTSTR lpszMenuName; ; / / menu name
LPCTSTR lpszClassName; / / class name
WNDCLASS;
8, window class registration:
ATOM RegisterClass (
CONST WNDCLASS * lpWndClass / / address of structure with class
; / / data