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.
备注
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 Application 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.
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 Solution Explorer, right-click the Polygon project.
On the shortcut menu, click Properties.
Click on Linker. Change the Per-User Redirection option to Yes.
Click OK.
In the next step, you will add a control to your project.
See Also
Reference
ATL Tutorial: ActiveX Control in a Web Page
Change History
Date |
History |
Reason |
---|---|---|
January 2011 |
Updated for accuracy. |
Customer feedback. |