Adding a Method to an MFC ActiveX Control
Overview | How Do I ... Topics
You can define new methods for MFC-based ActiveX control interfaces. When defining methods for control interfaces, you can create your own method, choose from a list of stock methods for the control, or customize a stock method. When you choose a stock method without customizing it, Visual C++ creates a definition for the method in the .odl file, but does not generate any implementation code in your class (.cpp or .h) files.
To add a method to an MFC ActiveX control
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, select the Automation tab, then click the Add Method button.
In the External name list box, enter the name you want to use to identify this method to automation clients, or choose from the list of available stock events.
To create your own method, type in a unique name. If you choose from the list, you can either use the stock implementation or customize it. The name you specify here is reflected in the Internal name box.
If you are creating a new method, or customizing a stock method and would like to specify a distinct internal name for the member function that will send the method, type it into the Internal name box.
The Internal name box is not available for stock implementations of stock methods.
If applicable, select a return type from the drop-down list.
You cannot alter the return type for stock methods.
For methods you are defining, use the Parameter list to specify any parameters you want the method to take. For each parameter you wish to define:
Enter a name for the parameter in the Name box.
Choose a valid type from the Type list.
When you are satisfied with the method as you’ve defined it, click OK to exit the Add Method dialog box.
The new method is displayed as an icon in ClassView under the dispinterface where it is defined. For custom methods, or stock methods with custom implementations, it is also displayed under the class that implements it. You can double-click the icon under the dispinterface to jump to the .odl file, and you can double-click the icon under the class to jump to the .cpp file.