Overview | How Do I ... Topics
When you use the Add Method dialog box to define a new method for an ATL or user-defined interface, ClassView defines two default method 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 method 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, the return type is always HRESULT.
Note HRESULT is the recommended return type, even for custom interfaces, since it provides a standard way to return error codes.
The Implementation area reflects the default id and helpstring attributes, and the method return type.
The Implementation area reflects the parameters you enter here.
Only four attributes take a value: id, call_as, helpstring, and helpcontext. For more information, see the Attributes Definition Table.
The Implementation area now displays any attributes you have just specified. You can continue to add, delete, or modify attributes by returning to the Edit Attributes dialog box, until you close the Add Method dialog box.
The method is immediately visible as an icon in ClassView, under the interface where it is defined.
By double-clicking the method icon, you can examine the .idl or .odl file to see the new method definition.
For ATL interfaces, a stub method implementation is added to the .cpp file, and a reference to the method is 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.
Add a method to an MFC dispinterface