Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C++/CLI C MFC ATL WTL STL
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 10:11am
swinder134
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) 
{
	// TODO: Add your specialized code here and/or call the base class
	// ESC key
	if(pMsg->wParam == VK_ESCAPE) { return TRUE; }

	return CDialog::PreTranslateMessage(pMsg);
}
  Permalink  
Comments
Jörgen Sigvardsson at 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
0 Sergey Alexandrovich Kryukov 535
1 OriginalGriff 275
2 BillWoodruff 260
3 Shweta N Mishra 244
4 Deepu S Nair 230
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,818
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,755


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 13 Jan 2012
Copyright © CodeProject, 1999-2014
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