<Previous Lesson

Visual Programming

Next Lesson>

Lesson#10

Architecture of standard Win32 Application

CREATING WINDOW APPLICATION 2
STEP 1 (REGISTERING A WINDOW CLASS) 2
S
TEP 2 (CREATING WINDOW) 3
10.2 ABOUT MESSAGES 4
WINDOWS MESSAGES 5
M
ESSAGE TYPES 5
S
YSTEM-DEFINED MESSAGES 5
A
PPLICATION-DEFINED MESSAGES 7
M
ESSAGE ROUTING 7
Q
UEUED MESSAGES 8
N
ONQUEUED MESSAGES 9
M
ESSAGE HANDLING 10
M
ESSAGE LOOP 10
W
INDOW PROCEDURE 11
M
ESSAGE FILTERING 12
P
OSTING AND SENDING MESSAGES 12
POSTING MESSAGES 12
SENDING MESSAGES 13
M
ESSAGE DEADLOCKS 13
B
ROADCASTING MESSAGES 14
S
TEP 3 (FETCHING MESSAGES AND MESSAGE PROCEDURE) 15
S
TEP 4 (WINMAIN FUNCTION) 16
Summary 17
Architecture of standard Win32 Application 2
the system to send them to the appropriate window procedure for processing.
With the exception of the WM_PAINT message, the system always posts messages at
the end of a message queue. This ensures that a window receives its input messages in the
proper first in, first out (FIFO) sequence. The WM_PAINT message, however, is kept in
the queue and is forwarded to the window procedure only when the queue contains no
other messages. Multiple WM_PAINT messages for the same window are combined into
a single WM_PAINT message, consolidating all invalid parts of the client area into a
single area. Combining WM_PAINT messages reduces the number of times a window
must redraw the contents of its client area.
The system posts a message to a thread's message queue by filling an MSG structure and
then copying it to the message queue.
Information in MSG includes:
typedef struct tagMSG {
HWND hWnd;
UINT message;
WPARAM wParam,
LPARAM lParam,
DWORD time,
POINT pt
}MSG;
Architecture of standard Win32 Application 9
hWnd: The handle of the window for which the message is intended (hWnd)
message: The message identifier (message)
wParam: The two message parameters (wParam and lParam)
lParam: The time the message was posted (time)
time: The mouse cursor position (pt)
A thread can post a message to its own message queue or to the queue of another thread
by using the PostMessage or PostThreadMessage function.
An application can remove a message from its queue by using the GetMessage
function.To examine a message without removing it from its queue, an application can
use the PeekMessage function. This function fills MSG with information about the
message.
After removing a message from its queue, an application can use the DispatchMessage
function to direct the system to send the message to a window procedure for processing.

<Previous Lesson

Visual Programming

Next Lesson>

Home

Lesson Plan

Topics

Go to Top

Next Lesson
Previous Lesson
Lesson Plan
Topics
Home
Go to Top