Q:

How to delete event handler automatically in a MFC CDialog class?

I am using Visual C++ 2010 & MFC to write a small dialog-based application.
I click a control (such as a "static text" control) in the dialog，and the corresponding class creates a function and variable automatically.
Now I find the event handler is useless. How can I delete the event handler automatically?

A:

Well, you can right click it in one of the propert windows and choose delete event handler. But what it will do is comment out the code.
It can also be done from the ClassWizard. Quote:

With ClassView and WizardBar, deleting a message-handling function is the same as deleting any other member function. ClassView and WizardBar:

delete the function declaration
removes any associated map entry from the MSG, MESSAGE or DISPATCH map
and comment out the function body, or definition, so that you can easily delete it if you wish.

This includes variables. There is more information about other ways here

Class Wizard

Right-click the dialog resource and choose Class Wizard

Select the event handler you want to delete and then choose Delete Handler

Class View

Select the class first so that it has focus:

Click the lightening bolt on the Properties pane and then expand the control to see the events:

Click on the drop arrow and select Delete:

Hopefully this are enough examples to show you how you can delete functions. Please let me know if you want me to provide you with more information.

