Click here to Skip to main content
12,953,379 members (50,765 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi experts,

I have an Application in MFC using single dialog window.

Problem i am facing is, it exits when i press escape key.

i want it to exit when i press "Exit" button that i made my self and also by pressing "x"(default close button provided in dialog) button on top right corner of window but not by "esc" key.

I tried emptying the implementation of "OnCancel" function. It solves the problem of "esc" key, but it also disables, exit when i press "x" button.

Please help me, it is very annoying when i accidentally press exit and window goes away.

If possible, tell me way to add, minimize button along with "x"(close) button on the top.

Regards,
Swinder....
Posted 8-Aug-09 9:11am
swinder138
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

See here.

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Also, one use use PreTranslateMessage to intercept the ESC key. Add the function to the dialog using the class wizard, then check for the ESC key.

BOOL CDxf2NastranDlg::PreTranslateMessage(MSG* pMsg) <br />{<br /> // TODO: Add your specialized code here and/or call the base class<br /> // ESC key<br /> if(pMsg->wParam == VK_ESCAPE) { return TRUE; }<br /><br /> return CDialog::PreTranslateMessage(pMsg);<br />}<br />
  Permalink  
Comments
Jörgen Sigvardsson 1-Oct-10 18:28pm
   
Now that's using a sledge hammer to drive in a nail!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

U can add minimize/maximize button on top of the dialog box from the property of the dialog box.
  Permalink  
    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,930


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 13 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100