Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

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?
   
0
sjhunjhunuwala
Asked:
sjhunjhunuwala
1 Solution
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now