windows_programming_notes.nbk: Home | Index | Next Page: WM_POWER | Previous Page: WM_PALETTECHANGED
WM_PARENTNOTIFY
The WM_PARENTNOTIFY message is sent to the parent of a child window when the child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window. When the child window is being created, the system sends WM_PARENTNOTIFY just before the CreateWindow or CreateWindowEx function that creates the window returns. When the child window is being destroyed, the system sends the message before any processing to destroy the window takes place.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_PARENTNOTIFY
WPARAM wParam, // event and child window identifier
LPARAM lParam // child handle or cursor coordinates
);
Parameters
- wParam
The low-order word of wParam specifies the event for which the parent is being notified. This parameter can be one of the following values. Value Meaning
- WM_CREATE The child window is being created.
- WM_DESTROY The child window is being destroyed.
- WM_LBUTTONDOWN The user has placed the cursor over the child window and has clicked the left mouse button.
- WM_MBUTTONDOWN The user has placed the cursor over the child window and has clicked the middle mouse button.
- WM_RBUTTONDOWN The user has placed the cursor over the child window and has clicked the right mouse button.
- WM_XBUTTONDOWN Windows 2000 or later: The user has placed the cursor over the child window and has clicked the first or second X button.
The meaning of the high-order word of wParam depends on the value of the low-order word of wParam, as shown in the following table. LOWORD(wParam) Meaning of HIWORD(wParam)
- WM_CREATE Identifier of the child window.
- WM_DESTROY Identifier of the child window.
- WM_LBUTTONDOWN Undefined.
- WM_MBUTTONDOWN Undefined.
- WM_RBUTTONDOWN Undefined.
- WM_XBUTTONDOWN Windows 2000 or later: Indicates which button was pressed. This parameter can be one of the following values:
- XBUTTON1
- XBUTTON2
lParam
The meaning of lParam depends on the value of the low-order word of wParam, as shown in the following table. LOWORD(wParam) Meaning of lParam
WM_CREATE Handle of the child window.
WM_DESTROY Handle of the child window.
WM_LBUTTONDOWN The x-coordinate of the cursor is the low-order word, and the y-coordinate of the cursor is the high-order word.
WM_MBUTTONDOWN The x-coordinate of the cursor is the low-order word, and the y-coordinate of the cursor is the high-order word.
WM_RBUTTONDOWN The x-coordinate of the cursor is the low-order word, and the y-coordinate of the cursor is the high-order word.
WM_XBUTTONDOWN The x-coordinate of the cursor is the low-order word, and the y-coordinate of the cursor is the high-order word.
Return Values
If an application processes this message, it should return zero.
Remarks
This message is also sent to all ancestor windows of the child window, including the top-level window.
All child windows, except those that have the WS_EX_NOPARENTNOTIFY extended window style, send this message to their parent windows. By default, child windows in a dialog box have the WS_EX_NOPARENTNOTIFY style, unless the CreateWindowEx function is called to create the child window without this style.
Requirements
- Windows NT/2000 or later: Requires Windows NT 3.1 or later.
- Windows 95/98/Me: Requires Windows 95 or later.
- Header: Declared in Winuser.h; include Windows.h.
windows_programming_notes.nbk: Home | Index | Next Page: WM_POWER | Previous Page: WM_PALETTECHANGED
Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time