Tech Support > Microsoft Windows > Development Resources > message propagation in win32?
message propagation in win32?
Posted by kilik3000@gmail.com on May 9th, 2007



How does win32 message propagation work?

is a window.

What I don't understand is how a message either gets to or doesn't get
to a child.

Let's say there is a mouse move message sent by windows to my
application b/c I move the mouse. What is the progression from there?

So if we say I mouse move over a button on my form...how does it go
from windows to the form to the button and then result in say a
highlight effect on the button?

Any insight will be greatly appreciated.

-Thx


Posted by Michael K. O'Neill on May 12th, 2007



<kilik3000@gmail.com> wrote in message
news:1178723133.427119.104690@q75g2000hsh.googlegr oups.com...
The message doesn't go from Windows to the form to the button; if goes
directly from Windows to the button without ever stopping at the form.

A typical message loop in your Win32 program looks something like this:

while ( GetMessage( &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}

The call to GetMessage() gets the topmost message in the application's
message queue. It's the Windows OS that creates queues for each different
application, and puts the messages (like your WM_MOUSEMOVE message) into the
queue for the correct application. Inside the message there's a field which
holds the handle of the window to which the message is directed. The
DispatchMessage() function looks at that field, and then sends the message
directly to the window procedure (WndProc(), another function that you write
for your application) for the destination window. Inside the WndProc(), the
appearance of the button will be changed to the highlight effect.

You can read about message handling at "Messages and Message Queues " at
http://msdn2.microsoft.com/en-us/library/ms632590.aspx

Mike




Similar Posts