[Resolved] MFC: Show Dialog?
I'm showing a dialog via this code:
Code:
BOOL CListworkApp::InitInstance() {
CListworkDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK) {
} else if (nResponse == IDCANCEL) {
}
return FALSE;
}
Which is the default code provided by the wizard. However, when I remove the buttons and the code, the app disappears when enter is pressed.
I'm assuming there's another method to show the dialog so that this doesn't happen?
Re: Re: MFC: Show Dialog?
Quote:
Originally posted by transcendental
Even if you had removed the ok button and its code, the default code called, when enter key is pressed, is still OnOk().
1 solution is to change the default button, using SetDefID(); in the Initdialog() handler.
example,
SetDefID(ID_MY_OTHER_BUTTON);
SetDefID() is a member function of CDialog. Look it up in the MSDN for more details.
P.S. I don't know how well it works in a modeless dialog, I had only used it in modal dialog.
But there isn't a button on my dialog. I only want it to close when the X is clicked.
I'm not sure how to fix this...any help would be appreciated.