Adding a Method to an MFC Dispinterface
Overview | How Do I ... Topics
You can define new methods for automation-enabled MFC classes that were created by using the MFC AppWizard or ClassWizard.
To add a method to an MFC dispinterface
Open the Add Method dialog box in one of the following ways:
In ClassView, rest your cursor on the interface, and click the right mouse button to invoke the shortcut menu, then choose Add Method.
In ClassWizard, for an automation-enabled class, choose the Automation tab and then click the Add Method button.
In the External Name drop-down list box, enter the name you want to use to identify this method to automation clients.
This name is reflected in the Internal Name text box.
If you would like to specify a distinct internal name for this method, type it into the Internal Name box.
This is the name of the member function that will send the method.
Select a return type from the drop-down list.
In the Parameter list area, for each parameter you wish to define:
Enter a name for the parameter in the Name text box.
Select a valid type from the Type drop-down list.
When you are satisfied with the method as you’ve defined it, click OK to exit the Add Method dialog box.
Visual C++ adds the new method declaration to the .odl file, a stub method implementation to the .cpp file, and a reference to the method in the .h file for the class.
The new method is displayed as an icon in ClassView under the interface where it is defined. By double-clicking the method icon, you can examine the .odl file to see its declaration.