Step 2: Adding the Server Object
In this step, you will use Class View to add objects to the project. You need to add a single ATL object (named
CDispServ) to the server. This object also serves as an event source.
To add a class to the project
- In Class View, right-click the DispServer project.
- On the shortcut menu, click Add and then click Add Class.
The Add Class dialog box appears.
- Select ATL Simple Object and click Open.
The ATL Simple Object Wizard appears.
- In the Short name field, type DispServ.
The remaining fields are automatically completed.
The additional fields contain information on the name of the class as well as the names of the files that should be created. The Type field is a description of the object, while the ProgID field is the readable name that can be used to look up the CLSID of the object. Note that the Attributed box is selected and unavailable. An ATL object created by the wizard in an attributed project is always attributed.
- Click the Options tab in the wizard.
- On the Options tab, select Connection points support. This allows the object to act as an event source.
- Click Finish to generate the
Note in Class View that the
CDispServ class, as well as the
IDispServ and _
IDispServEvents interfaces, have been created and are now visible.
To implement the new class, the wizard added two new files to the project:
- DispServ.h contains most of the implementation of the
CDispServclass, as well as the interfaces. The
CDispServclass has automatically been made a COM event source through the event_source attribute with the
_IDispServEventsinterface automatically specified as the event interface for
CDispServ. UUIDs, progids, help strings, and version numbers have been automatically generated for the class and the interfaces.
- DispServ.cpp contains the remainder of the
CDispServclass. At this point, it includes a few necessary files.
You can build the application by clicking Build DispServer from the Build menu, though DispServer does not actually do anything interesting yet. However, it does have the capability to register itself. This is done automatically when the project is built.
The next step implements the functionality of the