0% found this document useful (0 votes)
33 views2 pages

The Window Procedure: (Process WM - CREATE Message)

The window procedure determines how a window responds to user input and messages. It receives messages identified by numbers defined in WINUSER.H. Within the window procedure, a switch statement is typically used to check the message and process it accordingly, returning 0 if processed or passing it to DefWindowProc otherwise. The sample window procedure in the document processes WM_CREATE, WM_PAINT, and WM_DESTROY messages and passes all others to DefWindowProc.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

The Window Procedure: (Process WM - CREATE Message)

The window procedure determines how a window responds to user input and messages. It receives messages identified by numbers defined in WINUSER.H. Within the window procedure, a switch statement is typically used to check the message and process it accordingly, returning 0 if processed or passing it to DefWindowProc otherwise. The sample window procedure in the document processes WM_CREATE, WM_PAINT, and WM_DESTROY messages and passes all others to DefWindowProc.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Windows Procedure The Window Procedure The window class has been registered, the window has been

created, the window has been displayed on the screen, and the program has entered a message loop to retrieve messages from the message queue. The real action occurs in the window procedure. The window procedure determines what the window displays in its client area and how the window responds to user input. The Window Procedure LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) The four parameters to the window procedure are identical to the first four fields of the MSG structure Processing the Messages Every message that a window procedure receives is identified by a number, which is the message parameter to the window procedure. The Windows header file WINUSER.H defines identifiers beginning with the prefix WM ("window message") for each type of message. Generally, Windows programmers use a switch and case construction to determine what message the window procedure is receiving and how to process it accordingly. When a window procedure processes a message, it should return 0 from the window procedure. All messages that a window procedure chooses not to process must be passed to a Windows function named DefWindowProc. The value returned from DefWindowProc must be returned from the window procedure.

In HELLOWIN, WndProc chooses to process only three messages: WM_CREATE, WM_PAINT, and WM_DESTROY. The window procedure is structured like this: switch (iMsg) { case WM_CREATE : [process WM_CREATE message] return 0 ; case WM_PAINT : [process WM_PAINT message] return 0 ; case WM_DESTROY : [process WM_DESTROY message] return 0 ; } return DefWindowProc (hwnd, iMsg, wParam, lParam) ; It is important to call DefWindowProc for default processing of all messages that your window procedure does not process. Otherwise behavior regarded as normal, such as being able to terminate the program, will not work. Attachments:

You might also like