Suppress return and escape in a dlg
-
I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind
Add
OnOK()
andOnCancel()
handlers and don't call the base class handlers. Ie,void CMyDialog::OnOK()
{
CDialog::OnOK(); // Wizard generated code
}just comment out the Wizard generated call to
CDialog::OnOK()
and all will work as you expect. Rob Manderson Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004 -
I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind
See the FAQ 7.4 How do I prevent a dialog from closing when the user presses Enter or Esc?[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- I even hear the Windows "OMG I booted up fine" sound. -- Paul Watson diagnosing hardware problems.
-
I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind
Alternatively you can override PreTranslateMessage
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
// Check for a keypress
if (pMsg->message == WM_KEYDOWN)
{
// Check for CR and ESC
if ((pMsg->wParam == 13) || (pMsg->wParam == 27))
{
// Soak them up, no further processing
return TRUE;
}
}return CDialog::PreTranslateMessage(pMsg);
}
Sorry cant remember the VK defns (its too late!) Ant.