Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing a test application in mfc, On clicking on the "Enter key", the application gets disappeared.
Is there any way to prevent application from getting terminated?

Thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 23-Jun-14 1:53am    
There is no such problem: an application won't terminate if you don't terminate it yourself. You screw up something; who knows what? First of all, an unhandled exception in a main thread will terminate the application, but you have to catch them on the top stack frame (at least) of each thread. As we cannot know what could you screw up (it could be pretty much everything), the post makes no sense at all.
—SA
Utheen 23-Jun-14 4:09am    
Hi,
It was not due to an unhandled exception, it happens because the Okay button click was not handled properly.

The most likely explanation is that there is an "OK" key or similar on the form which takes the ENter key - it's acting as an "Accept" button - and that closes the form, which closes the application. Put a breakpoint in each of your button handler code functions and you should find which one pretty easily.
 
Share this answer
 
Comments
Utheen 23-Jun-14 3:00am    
Yes , I didn't notice the "OK" key, that is why this problem happens. The issue resolved on handling the "OK" button. Thank you so much.
OriginalGriff 23-Jun-14 3:17am    
You're welcome!
Override the OnOK method in your dialog class.
Similarly, to prevent the dialog closing on pressing the escape key, override the OnCancel method in your dialog class.
 
Share this answer
 
Comments
Utheen 23-Jun-14 4:07am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900