|
|
|
|
Lesson#10
|
Architecture of standard Win32 Application
|
|
|
|
CREATING WINDOW APPLICATION 2
STEP
1 (REGISTERING
A WINDOW
CLASS)
2
STEP
2 (CREATING
WINDOW)
3
10.2 ABOUT MESSAGES
4
WINDOWS
MESSAGES
5
MESSAGE
TYPES
5
SYSTEM-DEFINED
MESSAGES
5
APPLICATION-DEFINED
MESSAGES
7
MESSAGE
ROUTING
7
QUEUED
MESSAGES
8
NONQUEUED
MESSAGES
9
MESSAGE
HANDLING
10
MESSAGE
LOOP
10
WINDOW
PROCEDURE
11
MESSAGE
FILTERING
12
POSTING
AND SENDING
MESSAGES
12
POSTING
MESSAGES
12
SENDING
MESSAGES
13
MESSAGE
DEADLOCKS
13
BROADCASTING
MESSAGES
14
STEP
3 (FETCHING
MESSAGES AND MESSAGE
PROCEDURE)
15
STEP
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. |
|
|
|