Creating an ATL Project

The easiest way to create an ATL project is to use the ATL COM AppWizard. You can then add objects or controls to your project using the ATL Object Wizard. Go through the ATL Tutorial to insert a control and add custom properties and events.

This article:


Using the ATL COM AppWizard

To create a project using the ATL COM AppWizard:

  1. Open Developer Studio. Click New on the File menu, click Project Workspace, and click OK.
  2. Choose ATL COM AppWizard as your application type.
  3. Enter a project name.
  4. Click Create.

The ATL COM AppWizard displays a dialog box showing options that apply to your ATL project:

Click Finish to generate the project. The AppWizard then displays information about the project that it is creating and then displays the newly created project in the Project Workspace.

Note When you build your project, you can choose a MinSize or MinDependency configuration. MinSize will generate a smaller component, since shared code will be used from atl.dll. In this case, you must distribute atl.dll with your component. MinDependency will generate a larger component, since all necessary code will be linked in with your component.

Back To Top


Files Generated by the ATL COM AppWizard

Choose the FileView tab in the Project Workspace and expand by clicking + to see the files generated for your project:

Test.cppContains the implementation for your DLL’s exports for an in-process server and the implementation of WinMain for a local server. For a service, this additionally implements all the service management functions.
Test.defTypically, contains a list of your DLL’s exports. Generated only for an in-process Server.
Test.idlIncludes the definitions for all your interfaces. As an Interface Definition Language (.idl) file, it will be processed by the MIDL compiler to generate the Test.tlb type library and marshaling code.
Test.rcContains the resource information for your project.
Resource.hThe header file for the resource file.
StdAfx.cppIncludes the files StdAfx.h and Atlimpl.cpp.
StdAfx.hIncludes the ATL header files.

Back To Top


Adding Objects and Controls

After generating a project with the ATL COM AppWizard, you can add an object or a control using the ATL Object Wizard. For each COM object or control you add, the wizard will generate .cpp and .h files, as well as an .rgs file for script-based registry support.

To add an object or a control using the ATL Object Wizard:

  1. With your ATL project open, choose Component from the Insert menu. Component Gallery opens.
  2. In Component Gallery, choose the ATL tab.
  3. On the ATL tab, select the ATL Object Wizard, then click the Insert button. The ATL Object Wizard opens.

 The ATL Object Wizard displays the categories of objects on the left and the icons of the objects in each category on the right. Choose a category, and the icons of the objects that category contains are displayed.

ATL Objects

ATL Controls

ATL Miscellaneous

Double-click the control or object you want to insert. The ATL Object Wizard displays a dialog box showing options that apply to your object or control.

Note Depending on the type of object or control you select, some of the pages and options described below may not be available.

In the Names page, enter class and file names. By default, the name you enter for Short name becomes the root for all other names in this page. You can enter your own names rather than accept these defaults.

In the Attributes page, select a threading model, interface type, and aggregation support:

In the Miscellaneous page, choose the features for the object.

In the Stock Properties page, select the stock properties you want the object to support, such as Caption or Border Color. You can select all the stock properties at once by clicking the >> button.

In the Strings page, enter names for the property page object.

Back To Top


Adding a New Interface to an Existing Object

To add a new interface to an existing object:

  1. Add the definition of your new interface to the .idl file.
  2. Derive your object from the interface.
  3. Create a new COM_INTERFACE_ENTRY for the interface.
  4. Implement methods on the interface.

Back To Top