Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

CWnd::SendMessageToDescendants

Call this member function to send the specified Windows message to all descendant windows.

void SendMessageToDescendants(
   UINT message,
   WPARAM wParam = 0,
   LPARAM lParam = 0,
   BOOL bDeep = TRUE,
   BOOL bOnlyPerm = FALSE 
);

Parameters

message
Specifies the message to be sent.
wParam
Specifies additional message-dependent information.
lParam
Specifies additional message-dependent information.
bDeep
Specifies the level to which to search. If TRUE, recursively search all children; if FALSE, search only immediate children.
bOnlyPerm
Specifies whether the message will be received by temporary windows. If TRUE, temporary windows can receive the message; if FALSE, only permanent windows receive the message. For more information on temporary windows see Technical Note 3.

Remarks

If bDeep is FALSE, the message is sent just to the immediate children of the window; otherwise the message is sent to all descendant windows.

If bDeep and bOnlyPerm are TRUE, the search continues below temporary windows. In this case, only permanent windows encountered during the search receive the message. If bDeep is FALSE, the message is sent only to the immediate children of the window.

Example

// change font of child controls of a dialog
BOOL CCtrldilg::OnInitDialog()
{
   CDialog::OnInitDialog();

   LOGFONT lf;  
   // redraw of child controls not needed in OnInitDialog since controls 
   // aren't drawn yet.
   short int fRedraw= FALSE; 

   memset(&lf, 0, sizeof(LOGFONT));  // Clear out structure.
   lf.lfHeight = 15;                 // Request a 15-pixel-high font
   strcpy(lf.lfFaceName, "Arial");   // with face name "Arial".
   m_font.CreateFontIndirect(&lf);   // Create the font. 

   SendMessageToDescendants(WM_SETFONT,
      (WPARAM)m_font.m_hObject,  //handle to font
      MAKELONG ((WORD) fRedraw, 0), 
      FALSE);  // send to all descendants(TRUE) or just children of *this (FALSE)

   return TRUE;
}

See Also

CWnd Overview | Class Members | Hierarchy Chart | CWnd::SendMessage | CWnd::FromHandlePermanent | CWnd::FromHandle

Show:
© 2015 Microsoft