Creating the Basic Control

The first step in developing an ActiveX control is to use the MFC ActiveX ControlWizard to create the project. ControlWizard creates an ActiveX control project framework, including a basic set of classes, resources, and definition files. You will use ControlWizard to create the first version of the Circle control, which can draw itself as the outline of an ellipse. No properties, events, or methods are implemented in this step.

Suggested Reading

  • , Visual C++ Programmer's Guide

To create the Circle control

  1. On the File menu, click New.

  2. In the New dialog box, click the Projects tab.

  3. Click MFC ActiveX ControlWizard.

  4. In the Project Name text box, type Circ.

  5. Using the Location edit box and Browse button, select an appropriate project path.

  6. In the Platforms box, choose the appropriate platforms (in this case, Win32).

  7. Click OK.

    The first MFC ActiveX ControlWizard dialog box appears.

  8. Click Finish.

    ActiveX ControlWizard closes and the New Project Information dialog box appears.

  9. Click OK.

    The New Control Information dialog box closes and the project is created and opened in the development environment.

ControlWizard creates all of the necessary files to build the Circle control. Of these files, three class templates are created:

Class Files Comments
Circapp CIRC.H
CIRC.CPP
Implements the main DLL source. Typically, there is no need to modify this code.
CCircCtrl CIRCCTL.H
CIRCCTL.CPP
Implements the actual control functionality. Modify this class's code to implement control-specific behavior.
CCircPropPage CIRCPPG.H
CIRCPPG.CPP
Provides a template for the control's property page. Modify this class and its dialog template to implement a control-specific property page.

ControlWizard creates several other files that you modify later in this lesson and in subsequent lessons.

File Comments
CIRL.ODL Textually defines the control's type information. This file is modified by ClassWizard when you add properties, events, or methods to the control. MKTYPLIB.EXE uses this file as input to generate the type library (CIRC.TLB) information that is ultimately added to the control's executable file as a resource.
CIRC.RC Standard resource file. Contains a template for the control's property page.
CIRC.RC2 Contains user-defined resources that define a control's version information, include its type library information, and state that the control self-registers.
CIRCCTL.BMP The tool palette representation of the control.
CIRC.ICO The About box dialog icon.

ControlWizard also creates several other standard files: CIRC.CLW, CIRC.DEF, CIRC.MAK, CIRC.VCW, MAKEFILE, README.TXT, RESOURCE.H, STDAFX.CPP, and STDAFX.H.