How to prevent closing of dialog box on Esc key?

I have developed a Dialog based mfc application,using VC6.
  The problem is that if an escape key is pressed,the dialog based application exits.How can I prevent this from happening?
   
sjhunjhunuwalaAsked:
Who is Participating?
 
coreyfrostCommented:
Just provide an implementation of the virtual function OnCancel in your CDialog based class that does nothing. You can do this easily using class wizard for the object ID IDCANCEL. Here is the code to do it manually.

Add this to your dialog class definition (.h file):

virtual void OnCancel();

Add this to your dialog class implementation (.cpp file):

void CYourDialog::OnCancel()
{
}

If you used ClassWizard to add this method, you will need to remove the line of code it added to call the default implementation of OnCancel.


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.