Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/104069

From BetaArchive Wiki

INFO: SetParent and Control Notifications

Q104069



The information in this article applies to:


  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows Software Development Kit (SDK)





SUMMARY

An edit, list box, or combo box control sends notifications to the original parent window even after SetParent has been used to change the control's parent. A button control sends notifications to the new parent after SetParent has been used to change its parent.

Edit, list box, and combo box controls keep a private copy of the window handle of the parent at the time of creation. This handle is not changed when SetParent is used to change the control's parent. Consequently, the notifications (EN_*, LBN_*, and CBN_* notifications) go to the original parent.

Note that WM_PARENTNOTIFY messages go to the new parent and GetParent() returns the new parent. If it is required that notifications go to the new parent window, code must be added to the old parent's window procedure to pass on the notifications to the new parent.

For example:

   case WM_COMMAND:
     hwndCtl = LOWORD(lParam);

     // If notification is from a control and the control is no longer this
     //   window's child, pass it on to the new parent.
     if (hwndCtl && !IsChild(hWnd, hwndCtl))
         SendMessage(GetParent(hwndCtl), WM_COMMAND, wParam,  lParam);
     else Do normal processing; 

Button controls send notifications to the new parent after SetParent has been used to change the parent.

Additional query words: listbox combobox

Keywords : kbComboBox kbCtrl kbEditCtrl kbListBox kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin
Issue type : kbinfo
Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWinSDKSearch


Last Reviewed: July 12, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.