Adding an Event to an MFC ActiveX Control
Overview | How Do I ... Topics
When you use the to create a control, Visual C++ creates two interfaces, displayed as icons in ClassView. The first is the dispinterface that you use to add properties and methods. The second is the dispinterface that you use to define outgoing events.
To add an event to an MFC ActiveX control
Open the Add Event dialog box in one of the following ways:
In ClassView, rest your cursor on the event interface, click the right mouse button to invoke the shortcut menu, then choose Add Event.
In ClassWizard, for an automation-enabled class, select the Automation tab, then choose Add Event.
For stock events, select a name from the External name list. For new events you wish to define, type in the name in the External name text box.
This is the name automation clients will use to request an event from the control. The Internal name box displays a suggested member function name. You can optionally change that name.
For stock events, in the Implementation area, specify whether you will use the stock implementation or whether you will customize it.
If you are defining a new event, this area is unavailable.
For events you are defining, use the Parameter list to specify any parameters you want the event 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 finished defining the control event, click OK to exit the Add Event dialog box.
The event is visible as an icon in ClassView under the interface.
You can double-click the icon to jump to the definition in the .odl file. For custom events, or stock events with custom implementations, you can double-click the icon under the class that implements the interface (usually the control class) to jump to the .h file.