Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Esc exits application

Status
Not open for further replies.

shetlandbob

Programmer
Mar 9, 2004
528
GB
Ok,

Ive got a MFC dialog application, when I hit escape then it quits. I know this is calling the OnCancel() function, but if I override this how do I make the application quit from either the menu (my menu exit call ID_APP_EXIT - which in turn calls OnCancel()) or from the "X" in the top right of the dialog.

I'm pretty sure this is fairly straight forward, but cant for the life of me figure it out.

Thanks
 
There is a function called PreTranslateMessage!!!

Capture the WM_KEYDOWN there and nullify

Cheers,

Ravi
 
Cheers Ravi,

Did it by overriding the OnCancel() message

and then handling the WM_CLOSE message and changing the code generated from
Code:
CDialog::OnClose();
to:
Code:
CDialog::OnCancel();.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top