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:
To create a project using the ATL COM AppWizard:
- Open Developer Studio. Click New on the File menu, click Project Workspace, and click OK.
- Choose ATL COM AppWizard as your application type.
- Enter a project name.
- Click Create.

The ATL COM AppWizard displays a dialog box showing options that apply to your ATL project:
- Choose from one of three server types: Dynamic Link Library (DLL) for an in-process server,
Executable (EXE) for a local out-of-process server, or Service (EXE), a server that is also a
Windows NT service and runs in the background when NT starts up.
- Select Allow merging of proxy/stub code as a convenience when marshaling interfaces is required.
This option places the MIDL generated proxy and stub code in the same DLL as the server.
- Click the Support MFC check box to use MFC functionality (such as CString) in your server.
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
Choose the FileView tab in the Project Workspace and expand by clicking + to see the files generated
for your project:
Test.cpp | Contains the implementation for your DLLs 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.def | Typically, contains a list of your DLLs exports. Generated only for an in-process Server. |
Test.idl | Includes 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.rc | Contains the resource information for your project. |
Resource.h | The header file for the resource file. |
StdAfx.cpp | Includes the files StdAfx.h and Atlimpl.cpp. |
StdAfx.h | Includes the ATL header files. |
Back To Top
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:
- With your ATL project open, choose Component from the Insert menu. Component Gallery
opens.
- In Component Gallery, choose the ATL tab.
- 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
- Simple Object adds a minimal COM object.
ATL Controls
- Full Control adds an object that supports the interfaces for all containers.
- Internet Explorer Control adds an object that supports the interfaces needed by Internet Explorer,
including support for a user interface.
- Property Page adds an object that implements a property page.
ATL Miscellaneous
- Dialog adds a class that implements a dialog box.
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.
- Class is the name of the class implementing your object.
- CoClass is the name of the component class that contains a list of interfaces supported by the object.
- Interface is the name of the interface you create for your object. This interface contains your custom
methods. For full controls, Internet Explorer controls, and simple objects, the wizard creates an
interface with the name you specify. For property page objects, no custom interface is created, and
the wizard assigns IUnknown as the object interface. Dialog objects do not create an interface.
- Type is a description string for the object that goes into the registry.
- ProgID is a name that containers can use instead of the CLSID of the object.
In the Attributes page, select a threading model, interface type, and aggregation support:
- Choose Dual Interfaces if you want the object's interfaces to derive from IDispatch as well as
support your custom functions (the vtable has custom interface functions plus late-binding IDispatch
methods). This allows both COM clients and Automation controllers to access your object.
- Choose Custom Interfaces to derive the objects interfaces from IUnknown (the vtable has
custom interface functions and not IDispatch methods). A custom interface can be faster than a dual
interface, especially across process boundaries.
- Choose Only for aggregation if you want the object to be instantiated only if it is being aggregated.
- Check the ISupportErrorInfo checkbox to have your object implement the ISupportErrorInfo
interface for error reporting.
- Check the Support Connection Points checkbox to add support for connection points to the
object. The wizard will automatically derive the objects class from
IConnectionPointContainerImpl.
- Check the Free Threaded Marshaler checkbox to create a free-threaded marshaler object to
efficiently marshal interface pointers between threads in the same process.
In the Miscellaneous page, choose the features for the object.
- Choose Opaque to make your control completely opaque, so that none of the container shows
behind the control boundaries. This helps the container draw the control more quickly. The entire
control rectangle passed to your control classs OnDraw method. This option sets the
VIEWSTATUS_OPAQUE bit in the VIEWSTATUS enumeration.
- Choose Solid Background to make the controls background a solid color and not a pattern. This
option is meaningful only if the Opaque is option is also selected. This option sets the
VIEWSTATUS_SOLIDBKGND bit in the VIEWSTATUS enumeration.
- Choose Invisible at runtime to make your control invisible at run time. You can use invisible
controls to perform operations in the background, such as firing events at timed intervals.
- Choose Acts like button to enable your control to act like a button, in particular to display itself as
the default button based on the ambient property DisplayAsDefault.
- Choose Acts like label to enable your control to replace the container's native label.
- Choose Add control based on to superclass one of the standard window classes. The drop-down
list contains window class names defined by Windows. When you choose one of these, the wizard
adds a CContainedWindow member variable to your control's class.
CContainedWindow::Create will superclass the window class you specify.
- Choose Normalize DC to have your control create a normalized device context when it is called to
draw itself. This standardizes the control's appearance but is less efficient.
- Choose Insertable to have your control appear in the Insert Object dialog box of applications such
as Word and Excel. Your control can then be inserted by any application that supports embedded
objects through the Insert Object dialog box.
- Choose Windowed Only to force your control to be windowed, even in containers that support
windowless objects. If you do not select this option, your control will automatically be windowless in
containers that support windowless objects, and automatically be windowed in containers that do not
support windowless objects.
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.
- Title is the text that appears on the property pages tab.
- Doc String is a text string describing the page. The property frame could use the description in a
status line or tool tip. The standard property frame currently does not use this string.
- Helpfile is the name of the associated help file. The help file name should be the simple name without
a path. When the user presses Help, the frame opens the help file in the directory named in the value
of the HelpDir key in the property page registry entries under its CLSID.
Back To Top
To add a new interface to an existing object:
- Add the definition of your new interface to the .idl file.
- Derive your object from the interface.
- Create a new COM_INTERFACE_ENTRY for the interface.
- Implement methods on the interface.
Back To Top