The default button in a window created using CreateWindowEx ()

I created a window using CreateWindowEx , which works like a wizard dialog using the following code:

 DWORD dwStyle = WS_DLGFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_OVERLAPPEDWINDOW; m_hWnd = CreateWindowEx(WS_EX_APPWINDOW, _T("WIZARD"), _T("SETUP"), dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, WIZARD_WIDTH, WIZARD_HEIGHT, NULL, NULL, g_hInstance, this); 

In the WM_CREATE handler, I create the lower Next, Back, and Cancel buttons, on the Next button I set the BS_DEFPUSHBUTTON style, and I send DM_SETDEFID to the window using the ID of the next button. The button is displayed as the next button, but pressing return on any of the input fields does nothing (None have an ES_WANTRETURN set).

What am I doing wrong? I can post more code if I missed something vital.

Thanks J

+4
source share
1 answer

The DM_SETDEFID message DM_SETDEFID usually handled by DefDlgProc . If you call DefWindowProc instead, you need to process this message yourself, so that when IsDialogMessage your window a DM_GETDEFID message, you will know how to respond.

+2
source

All Articles