Cancelling ESC in dialogs
-
How do I cancel the ESCAPE key in a modeless dialog...? Do I override OnCancel or PreTranslateMessage or perhaps something totally different...? Thanx! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
How do I cancel the ESCAPE key in a modeless dialog...? Do I override OnCancel or PreTranslateMessage or perhaps something totally different...? Thanx! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
Create a handler for the WM_CHAR message inside of the PreTranslateMessage function, because the ESCAPE key is processed in the
IsDialogMessage
function for a dialog. This is the function that dispatches the message to the window, therefore you will have to process the WM_CHAR message before this function is called. -
Create a handler for the WM_CHAR message inside of the PreTranslateMessage function, because the ESCAPE key is processed in the
IsDialogMessage
function for a dialog. This is the function that dispatches the message to the window, therefore you will have to process the WM_CHAR message before this function is called.Thanx Kilo! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
How do I cancel the ESCAPE key in a modeless dialog...? Do I override OnCancel or PreTranslateMessage or perhaps something totally different...? Thanx! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
According to my experience, I would like to override OnCancel() function to handle the key event. It makes your program a little easier to use and fewer codes also. :)
-
According to my experience, I would like to override OnCancel() function to handle the key event. It makes your program a little easier to use and fewer codes also. :)
Does that actually work...? can you just return false in OnCancel to prevent escape from doing it's thing...? In anycase...it's pretty hard to beat:
if(pMsg->message==WM_KEYDOWN){
//Cancel escape and enter key
if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) return TRUE;
}Thats easy enough for me. Cheers "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
Does that actually work...? can you just return false in OnCancel to prevent escape from doing it's thing...? In anycase...it's pretty hard to beat:
if(pMsg->message==WM_KEYDOWN){
//Cancel escape and enter key
if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) return TRUE;
}Thats easy enough for me. Cheers "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
:| Misunderstanding, friend! I means that I will let the user press esc to quit after I release every resources in OnCancel() function. I donnot want to forbid this feature. I was not talking about coding but a solution. :) And Thanks your code also.:rose:
-
How do I cancel the ESCAPE key in a modeless dialog...? Do I override OnCancel or PreTranslateMessage or perhaps something totally different...? Thanx! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
The way I do this is by overriding OnCancel() such as:
void CMyDlg::OnCancel() {
GetAsyncKeyState(VK_ESCAPE);
if (!GetAsyncKeyState(VK_ESCAPE)) {
CDialog::OnCancel();
}
} -
How do I cancel the ESCAPE key in a modeless dialog...? Do I override OnCancel or PreTranslateMessage or perhaps something totally different...? Thanx! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
Happy birthday HockeyDude! :) :-D :-D ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------
-
Happy birthday HockeyDude! :) :-D :-D ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------
Thank you kindly. To be honest I totally forgot about that... I guess I should go ask friends/family for gifts now? Cheers! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr