在窗口CreateWindowEx调用期间,WM_CREATE消息发送到您的窗口过程。该lp参数包含一个指向CREATESTRUCT包含传递给参数CreateWindowEx。如果应用程序从WM_CREATE返回0,则创建窗口。如果应用程序返回-1,则创建将被取消。
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); }