This documentation is archived and is not being maintained.

Step 2: Adding the Server Object

Visual Studio .NET 2003

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

  1. In Class View, right-click the DispServer project.
  2. On the shortcut menu, click Add and then click Add Class.

    The Add Class dialog box appears.

  3. Select ATL Simple Object and click Open.

    The ATL Simple Object Wizard appears.

  4. 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.

  5. Click the Options tab in the wizard.
  6. On the Options tab, select Connection points support. This allows the object to act as an event source.
  7. Click Finish to generate the DispServ class.

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 CDispServ class, as well as the interfaces. The CDispServ class has automatically been made a COM event source through the event_source attribute with the _IDispServEvents interface 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 CDispServ class. 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 DispServer object.

On to Step 3 | Back to Step 1

See Also

Attributes Tutorial | ATL Article Overview | ATL Class Overview

Show: