JWood
JWood

Reputation: 2834

Default button in Window created with CreateWindowEx()

I've created a window using CreateWindowEx which functions as 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 bottom 'Next', 'Back' and 'Cancel' buttons, on the Next' button I set the style BS_DEFPUSHBUTTON and I send the DM_SETDEFID to the window with the ID of the next button. The button displays like a next button but hitting return on any of the input fields does nothing (None have ES_WANTRETURN set).

What am I doing wrong? I can post more code if I've missed anything vital out.

Thanks, J

Upvotes: 4

Views: 1290

Answers (1)

Rob Kennedy
Rob Kennedy

Reputation: 163287

The DM_SETDEFID message is normally processed by DefDlgProc. If you're calling DefWindowProc instead, then you need to handle that message yourself so that when IsDialogMessage sends your window a DM_GETDEFID message, you'll know how to respond.

Upvotes: 2

Related Questions