Home | Overview | How Do I | FAQ | Tutorial | Sample
This article provides step-by-step instructions for combining two existing ActiveX control projects into an existing OLE Custom Control Developer’s Kit (CDK) project. For clarity, the first control project is named Proj1; the second is named Proj2. After you have successfully completed this procedure, you will need to follow the steps detailed in the article ActiveX Controls: Converting a CDK Project to a Visual C++ Project to use this project with Visual C++ 4.0.
To protect the original code from becoming corrupted, work with the two controls in a separate directory. For example purposes, we’ve named the directory COMBINED. It is also recommended that you use the development environment for modifying and saving project files.
To successfully add an ActiveX control to an existing CDK project, you must:
The Proj1 and Proj2 directories both contain files that you can simply copy to the COMBINED directory with no changes. These files are used mainly to initialize the DLL and provide basic implementation of the control classes. Copy the following files into the COMBINED directory:
Also copy two other files, used as templates, to the COMBINED directory:
In a following section, this makefile will be modified to include the necessary files from PROJ1.
This file will eventually contain both the Proj1 and Proj2 ActiveX control interfaces.
Because there are two controls in the project, you will have to merge PROJ1.ODL into PROJ2.ODL. The .ODL file contains definitions for interfaces, so you need copy only those interfaces unique to Proj1 and insert them into the PROJ2.ODL file.
To merge PROJ1.ODL with PROJ2.ODL
//
// Type Library for Proj1.DLL
//
#include <otldisp.h>
[ uuid(A7A91CE8-B974-101A-8077-00AA00339DC7), version(1.0),
helpstring("PROJ1 ActiveX control module") ]
library Proj1
{
importlib("stdole.tlb");
importlib("stdtype.tlb");
// ****** Copy code below this line ********** //
[ uuid(A7A91CE6-B974-101A-8077-00AA00339DC7),
helpstring("Dispatch interface for PROJ1 Control") ]
dispinterface IProj1Ctrl
{
properties:
//{{AFX_ODL_PROP(CProj1Ctrl)
//}}AFX_ODL_PROP
methods:
//{{AFX_ODL_METHOD(CProj1Ctrl)
//}}AFX_ODL_METHOD
};
[ uuid(A7A91CE7-B974-101A-8077-00AA00339DC7),
helpstring("Event interface for PROJ1 Control") ]
dispinterface IProj1CtrlEvents
{
properties:
// Event interface has no properties
methods:
//{{AFX_ODL_EVENT(CProj1Ctrl)
//}}AFX_ODL_EVENT
};
// ****** Copy code above this line ********** //
// Class information for CProj1Ctrl
[ uuid(003256C3-AA78-11CE-8C98-00AA00339DC7),
helpstring("Proj1 Control"), control ]
coclass Proj1
{
[default] dispinterface _DProj1;
[default, source] dispinterface
_DProj1Events;
};
};
Now that you have moved the needed files from Proj1 to the COMBINED directory, incorporate them into the Proj2 makefile.
Note If PROJ2.MAK is an external makefile, edit it directly to add the new files from Proj1.
To incorporate Proj1 files into the Proj2 makefile
For this example, select the COMBINED directory and choose the Proj2 project (Proj2.dsp).
This inserts the file into the project.
The last modification required before building the project is to add the resources from PROJ1.RC to PROJ2.RC. This is easy to do because you can drag and drop resources from one project into another.
To add resources from Proj1 to Proj2
For this example select the COMBINED directory and choose the Proj2 project (Proj2.dsp).
For an example of a similar procedure, see Adding Help to Scribble After the Fact in Tutorials.
After completing the preceding steps, you can build the new project as you would any ActiveX control project. Once the project has been successfully built, register the controls. You can then use Test Container, or another container application, to test your ActiveX control. For more information on this procedure, see the article Test Container.
Please note that the .CLW file for Proj2 needs to be rebuilt to include the new classes added from the PROJ1 project.
To rebuild your .CLW file
For this example, select the COMBINED directory and choose the Proj2 project (Proj2.dsp).
A dialog box will appear, stating that your project’s .CLW file does not exist.
ClassWizard will now open with all classes from Proj2 loaded and accessible.