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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Disable the ESC key and X button? 1

Status
Not open for further replies.

Jordann

Programmer
May 21, 2001
2
US
Hi, I'm new(ish) to MFC so this question could be very simple to answer. (I hope so!)

Currently, in my inherited code, the ESC key will even
close the main Property Sheet, and its parent Dialog.

How do I programatically disable the ESC key so that it
closes and discards only certain sub-dialogs?

Thanks in advance
 
Try the subclassing methods. John Fill
1c.bmp


ivfmd@mail.md
 
Maybe something like this:

BOOL CMyDialog::preTranslateMessage(MSG* pMsg)
{
//Don't exit when Escape is pressed.
if(pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_ESCAPE))
return TRUE;

return CDialog::preTranslateMessage(pMsg);
}

PreTranslateMessage can be added via ClassWizard. As for the X button just check out the properties of your dialog and disable it.

bitwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top