Export (0) Print
Expand All

Step 1: Creating the Project 

This tutorial walks you step-by-step through a nonattributed ATL project that creates an ActiveX object that displays a polygon. The object includes options for allowing the user to change the number of sides making up the polygon, and code to refresh the display.

NoteNote

This tutorial creates the same source code as the Polygon sample. If you want to avoid entering the source code manually, you can download it from the Polygon sample abstract. You can then refer to the Polygon source code as you work through the tutorial, or use it to check for errors in your own project.

To create the initial ATL project using the ATL Project Wizard

  1. In the Visual Studio development environment, click New on the File menu, and then click Project.

  2. Click the Visual C++ Projects folder and select ATL Project.

  3. Type Polygon as the project name:

    New Project dialog box

    The location for the source code will usually default to My Documents\Visual Studio Projects, and a new folder will be created automatically.

  4. Click OK and the ATL Project Wizard opens.

  5. Click Application Settings to see the options available:

    ATL4 tutorial2 screenshot
  6. As you are creating a control, and a control must be an in-process server, leave the Server type as a DLL.

  7. In this tutorial, you will not be using attributes, so ensure that the Attributed check box is not selected.

  8. Leave the other options at their default values, and click Finish.

The ATL Project Wizard will create the project by generating several files. You can view these files in Solution Explorer by expanding the Polygon object. The files are listed below.

File Description

Polygon.cpp

Contains the implementation of DllMain, DllCanUnloadNow, DllGetClassObject, DllRegisterServer, and DllUnregisterServer. Also contains the object map, which is a list of the ATL objects in your project. This is initially blank.

Polygon.def

This module-definition file provides the linker with information about the exports required by your DLL.

Polygon.idl

The interface definition language file, which describes the interfaces specific to your objects.

Polygon.rgs

This registry script contains information for registering your program's DLL.

Polygon.rc

The resource file, which initially contains the version information and a string containing the project name.

Resource.h

The header file for the resource file.

Polygonps.def

This module definition file provides the linker with information about the exports required by the proxy and stub code that support calls across apartments.

stdafx.cpp

The file that will #include the ATL implementation files.

stdafx.h

The file that will #include the ATL header files.

In the next step, you will add a control to your project.

On to Step 2

Community Additions

ADD
Show:
© 2014 Microsoft