|
|
|
Child Windows and Message Maps |
|
A child window can have its own message map so that the messages from the
Windows OS to the child are not intercepted by the parent window. The child
window’s message map and message handler functions are completely independent of
the parent, and they are included in the Child Window class. The child would
respond to messages like the WM_PAINT and WM_DESTROY. However the
parent should be notified of any change in state of the child, like in the case
of WM_DESTROY that the child no longer exists.
The operating system allows the user to define and use his own message, known as
WM_USER. WM_USER is, of course, an ID (or preprocessor) constant. It is
defined by the operating system and is the next constant beyond the usual
messages defined in <windows.h>. When defining your own messages, you can assign
the ID of WM_USER to your first message, the ID of WM_USER + 1 to your next
message, and so on.
User defined messages can be used to communicate with the parent window and we
can have the handlers for this messages defined in the parent window class to
take the appropriate action. The message can be sent like
GetParent()->PostMessage(WM_USER);
The parent’s message map would include:
ON_MESSAGE(WM_USER, OnCloseChild)
|
|
NOTE:---------------------------------------------------------------------------------------------------------------------
The ON_MESSAGE message map entry allows any customized message to be
mapped. The general form of the message map entry for user messages is:
ON_MESSAGE(<message>, <member function>)
The message handler function for a customized message would be like:
LONG memberFunction(UINT, LONG);
-----------------------------------------------------------------------------------------------------------------------------
|
|
|
 |
| |
|
|
RELATED TOPICS |
|
What is a child window?
Popup Windows
Fixed Child Windows |
|
|
 |