A parent's OnParentNotify member function is called by the framework when its 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 calls OnParentNotify just before the Create member function that creates the window returns. When the child window is being destroyed, the system calls OnParentNotify before any processing takes place to destroy the window.
OnParentNotify is called for all ancestor windows of the child window, including the top-level window.
All child windows except those that have the WS_EX_NOPARENTNOTIFY style send this message to their parent windows. By default, child windows in a dialog box have the WS_EX_NOPARENTNOTIFY style unless the child window was created without this style by calling the CreateEx member function.
This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.