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.
ATL and MFC are not generally supported in the Express editions of Visual Studio.
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
In the Visual Studio development environment, click New on the File menu, and then click Project.
Click the Visual C++ Projects folder and select ATL Project.
Type Polygon as the project name.
The location for the source code will usually default to My Documents\Visual Studio Projects, and a new folder will be created automatically.
Click OK and the ATL Project Wizard opens.
Click Application Settings to see the options available.
As you are creating a control, and a control must be an in-process server, leave the Server type as a DLL.
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.
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.
This module-definition file provides the linker with information about the exports required by your DLL.
The interface definition language file, which describes the interfaces specific to your objects.
This registry script contains information for registering your program's DLL.
The resource file, which initially contains the version information and a string containing the project name.
The header file for the resource file.
This module definition file provides the linker with information about the exports required by the proxy and stub code that support calls across apartments.
The file that will #include the ATL implementation files.
The file that will #include the ATL header files.
In Solution Explorer, right-click the Polygon project.
On the shortcut menu, click Properties.
Click on Linker. Change the Per-User Redirection option to Yes.
In the next step, you will add a control to your project.