how could I disable Escape the dialog
-
how could I disable the function when I click escape, dialog auto close. just like overwrite OnOk() function? but it seems there's no OnEscape()
-
how could I disable the function when I click escape, dialog auto close. just like overwrite OnOk() function? but it seems there's no OnEscape()
The function you are looking for is
OnCancel
. Add a button with the IDIDCANCEL
if you don't already have one, double click it to create a handler (in MSVC++ 6.0). Remove the call to the base classOnCancel
and - finally - remove the button if you don't need it (although of course not the handler :-)) -
The function you are looking for is
OnCancel
. Add a button with the IDIDCANCEL
if you don't already have one, double click it to create a handler (in MSVC++ 6.0). Remove the call to the base classOnCancel
and - finally - remove the button if you don't need it (although of course not the handler :-))hmmm, if I overwrite OnCancel function, Esc key terminating the application is disabled, but I also can't terminate the application by click the top right cross button. What I want is just disable the key meanwhile the cross button still works.
-
hmmm, if I overwrite OnCancel function, Esc key terminating the application is disabled, but I also can't terminate the application by click the top right cross button. What I want is just disable the key meanwhile the cross button still works.
Then you might want to kill the keypress as early as possible, adding the virtual function
PreTranslateMessage
:BOOL CSomeDlg::PreTranslateMessage(MSG* pMsg)
{BOOL result = FALSE: if( pMsg->message == WM\_KEYDOWN && pMsg->wParam == VK\_ESCAPE ) result = TRUE; else result = CDialog::PreTranslateMessage(pMsg); return result;
}
-
Then you might want to kill the keypress as early as possible, adding the virtual function
PreTranslateMessage
:BOOL CSomeDlg::PreTranslateMessage(MSG* pMsg)
{BOOL result = FALSE: if( pMsg->message == WM\_KEYDOWN && pMsg->wParam == VK\_ESCAPE ) result = TRUE; else result = CDialog::PreTranslateMessage(pMsg); return result;
}
yes, this is what I want, thanks