So I am creating an button with the CreateWindowEx() function with it's parent(some value) in the parent WM_CREATE message handler part with it's own user data i.e the very last parameter of CreateWindowEx() is an pointer to some arbitrary data.

When an root/main window is created we receive an WM_CREATE or WM_NCCREATE message which allows us to Access this date with an CREATESTRUCT via the LPARAM value and assign it to the window via the SetWindowPtr(user data)

But when an child control is created and attached to this parent the parent window procedure doesn't receive the WM_CREATE message and the creation data for this button Passed into the CreateWindowEx () is lost

Is there a way to know when an child control has been successfully created(or ready to be displayed) in this parent in the parent window procedure so I can fulfill the above task?

Basically I want to create an heirarchy of controls (like in Java with panels and panes) with the parent creating it's children when it receives it's WM_CREATE(or some other message just to know when I can start assigning children to it)and those children in turn creating their own children when it receives their WM_CREATE messages and so own.

1 Answers

2
SoronelHaetir On Best Solutions

A parent window receives a WM_PARENTNOTIFY for child window creation (and a few other events). Be sure not to set the WS_EX_NOPARENTNOTIFY extended style (which is set by default for controls created by the dialog window class).

The data received as part of the WM_PARENTNOTIFY upon window creation includes the LPCREATESTRUCT that was sent to the window during WM_NCCREATE/WM_CREATE (WM_PARENTNOTIFY occurs only if the window was successfully created).