Adding a Property to an MFC ActiveX Control
Overview | How Do I ... Topics
When defining a property for an MFC ActiveX control interface, you can implement the property with a member variable or with Get/Set methods. Using the member variable implementation provides direct access to the property, whereas using Get and Set methods to implement the property enforces a controlled access. If you do implement the property via a member variable, you can also provide a notification function to alert you when the value of the property changes.
Note The member variable implementation is not valid for text properties such as Caption.
To add a property to an MFC ActiveX control
Open the Add Property dialog box in one of the following ways:
In ClassView, rest your cursor on the interface, click the right mouse button to invoke the shortcut menu, then choose Add Property.
In ClassWizard, for an automation-enabled class, click the Automation tab, then choose Add Property.
In the External name box, enter the name you want to use to identify this property to automation clients, or choose from the list of available stock properties.
To create your own property, type in a unique name. If you choose from the list, you can either use the Stock radio button to use inherited behavior, or you can select the Get/Set methods radio button to override the parent classes with your own function implementation.
For properties you are defining, select a type from the Type drop-down list.
You cannot modify the type for stock properties.
Choose an Implementation type for the property.
Your choice is reflected in the two text boxes below the Type drop-down list. By default, Member variable is selected, displaying the Variable name and Notification function text boxes. Selecting Get/Set methods displays the Get function and Set function boxes.
Optionally edit the text boxes that display the implementation functions.
For properties you’ve created, specify any custom parameters you’d like this property to take. In the Parameter list area, for each parameter you wish to define:
Enter a name for the parameter in the Name box.
Select a valid type from the Type drop-down list.
The Parameter list area is unavailable for a member variable implementation, since member variables don’t take parameters.
When you’ve completed the property definition, click OK to exit the Add Property dialog box.
The new property is displayed as an icon in ClassView under the dispinterface where it is defined. For custom properties, or stock properties 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.