Overview | How Do I ... Topics
When you use the Add Property dialog box to define a new property for an ATL, Java, or user-defined interface, ClassView defines two default attributes for you: id and helpstring. The id attribute assigns a DISPID. The helpstring is a placeholder for text that can be used in the interface, for example in a status bar or ToolTip.
To add a property to an interface or non-MFC dispinterface
This enables the parser to correctly identify the location of all elements in the file.
Note For ATL classes, the dispinterface (event source interface) is identified with the name I<MyObject>Events.
For dual interfaces and dispinterfaces, accept the default return type of HRESULT. Use the property type to pass a value by means of the parameter list rather than the return type.
Note HRESULT is the recommended return type, even for custom interfaces, since it provides a standard way to return error codes.
The Implementation area displays the options you’ve specified so far, in addition to the default id and helpstring attributes.
Any attributes you define for this property (see step 7) will be applied to the Get and Put functions specified here.
Only four attributes take a value: id, call_as, helpstring, and helpcontext.
For a description of the attributes available from the list, see the Attribute Definition Table.
The Implementation area reflects the attributes you have just specified. You can continue to add, delete, or modify attributes by returning to the Edit Attributes dialog box, until you exit the Add Property dialog box.
The property in its Get and Put variants is now visible as an icon in ClassView, under the interface where it is defined. You can double-click the icon to view the new property declaration in the .idl or .odl file.
For ATL interfaces, stub Get and Put functions are added to the .cpp file, and references to these functions are added to the .h file.
For ATL dispinterfaces (event source interfaces), the stub functions are added to the <ObjectName>cp.h file that gets created when you implement a connection point for the object. (You must first compile the .idl file.) For more information, see Adding Connection Points to an Object.