Win32 API Window messages WM_CREATE


Example

A WM_CREATE message is sent to your window procedure during the window's CreateWindowEx call. The lp argument contains a pointer to a CREATESTRUCT which contains the arguments passed to CreateWindowEx. If an application returns 0 from WM_CREATE, the window is created. If an application returns -1, creation is canceled.

LRESULT CALLBACK winproc(HWND hwnd, UINT wm, WPARAM wp, LPARAM lp)
{
    switch (wm) {
        case WM_CREATE:
            CREATESTRUCT *cs = (CREATESTRUCT *) lp;
            if (MessageBox(hwnd, 
                "Do you want to continue creating the window?", "", MB_YESNO)  
                                         == IDYES) {
                /* create window controls */
                return 0;
            }
            /* cancel creation */
            return -1;
    }
    return DefWindowProc(hwnd, wm, wp, lp);
}