Hello! I'm working on a library that's going to deal with windows (to be more specific, I'm wrapping some windows APIs that deals with window creation/destruction and messages (like a window click etc.) into OOP).

In the message handler this is what i have:

Code:
LRESULT CALLBACK zooppMessageHandler::msgHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    zooppMessageHandler *obj = (zooppMessageHandler*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
    int retVal = false;

    if(obj == NULL)
        if(msg == WM_CREATE || msg == WM_INITDIALOG)    //window creation
            {
                SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(((CREATESTRUCT*)lParam)->lpCreateParams));
                obj = (zooppMessageHandler*)GetWindowLongPtr(hwnd, GWLP_USERDATA);

                retVal = obj->OnInit();

                if(retVal != false)
                    return retVal;
                else
                    return DefWindowProc(hwnd, msg, wParam, lParam);
            }
        else if(msg == WM_PARENTNOTIFY && wParam == WM_CREATE)      //child window creation
            {
            }

    retVal = obj->Handle(msg, wParam, lParam);

    if(retVal != false)
        return retVal;
    else
        return DefWindowProc(hwnd, msg, wParam, lParam);
}
I know that so far it may look a bit unprofessional/unoptimized but i don't care about that yet. As you may see, for normal windows I pass the 'this' pointer into CreateWindowEx() function, and attach it's address to the window's handle with SetWindowLongPtr(). When a message (other tham WM_CREATE, WM_INITDIALOG etc.) comes I just grab the address of 'this' by calling GetWindowLongPtr() and then handle the message.

But...I ran into a problem regarding child windows. As far as I'm aware, when a child window is created the system won't send a WM_CREATE message but instead it will send a WM_PARENTNOTIFY message, wParam contains the child window's message (in my case WM_CREATE) and lParam it's handle. This means I can't pass the address of the object which issued the CreateWindowEx() function into the message handler.

Am I wrong? If no...how can i pass the object's address when creating child windows? For normal windows (as you see in the above code), I get the object's code from lParam which contains a pointer to a CREATESTRUCT structures in which member lpCreateParams points to the address of the object which issued a CreateWindowEx() function call.