MFC C++ VC 2010.
I have a dialog problem that is driving me nuts. I have a dialog that is sort of a version of AfxMessageBox with some added features. The default button needs to be settable and I can't seem to get that to work.
My .rc file looks like this
IDD_DLG_GENMSG DIALOGEX 0, 0, 240, 95
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
At start I enable of disable buttons as needed and the text on the button is changed programmatically as needed. No matter what I do, the first button listed in the resource file is always the default.
I tried a couple of methods described in these links
As I said, not this always had the first listed button as the default when I hit Return. As a work around I implemented a PreTranslateMessage override, but it never received the WM_KEYDOWN message and WK_RETURN key.
BOOL CDlgGenMsg::PreTranslateMessage(MSG* pMsg)
ASSERT(pMsg != NULL);
ASSERT(m_hWnd != NULL);
if((pMsg->message == WM_KEYDOWN))
if(pMsg->wParam == VK_RETURN)
What I have tried:
Detailed above in the body.
I'm probably missing something simple, but it's got me stumped.