As you saw previously, attributes take away a lot of repetitive clutter, enabling you to concentrate on the real logic in your code. The next step for this project is to create an ATL object that can be used by your MFC client later. Using the Solution Explorer, right-click the ATLAttributes project and select Add, Add Class. Select ATL Simple Object from the list in the dialog that is displayed and click Open to close it. You should now be presented with the ATL Simple Object Wizard, as shown in Figure 15.3. Give your object the name AttributeTest by filling in the edit box labeled Short Name and accept all the defaults by clicking Finish to close the dialog.
The next step is to add a function to the interface class you just created. Using the Class Viewer this time, expand the ATLAttributes project tree followed by the interface item. Right-click the IAttributeTest interface and select Add, Add Method. The Add Method Wizard will display. Give your method the name HelloWorld. We're going to use a parameter for this method, so in the drop-down box labeled Parameter Type, select CHAR* and give your parameter the name Buffer. This value will be returned to the client, so click the check box labeled Out. To add the parameter to the actual parameter list, click the Add button next to the Parameter Name field. The Add Method Wizard should now look similar to Figure 15.4. Close the dialog by clicking Finish.