Home | Overview | How Do I | FAQ | Tutorial | Sample
This article discusses converting existing OLE Custom Control Developer's Kit (CDK) projects (versions 1.0 and 1.1) to current Visual C++ projects. Because the support for ActiveX controls has been fully integrated into MFC, there are several changes that need to be made to an existing project before the control can be built successfully.
In summary, the necessary changes are:
For demonstration purposes, this article converts a project named SAMPLE32.
To remove all references to the OCS30 libraries
To remove RESIDENTNAME from the module definition file
RESIDENTNAME
from the file. There are typically four occurrences of this string.
For example, the following line of code:
DllCanUnloadNow @1 RESIDENTNAME
should be changed to:
DllCanUnloadNow @1 PRIVATE
Note that using the PRIVATE modifier avoids warnings from the linker. Similarly, symbols such as DllRegisterServer and DllUnregisterServer should also have the PRIVATE modifier.
The final step is to remove any existing directories and project files from earlier builds. This ensures a clean build with the new project settings.
To delete the contents of the project's output directories and the TLB16 subdirectory
One of the changes that occurred between the original release of the CDK and its integration into VC ++ 4.0, was the removal of the MFCANS32 DLL. This DLL was responsible for the ANSI/Unicode translation layer used for Unicode-based OLE interfaces with an ANSI-targeted control. If your control supported licensing, it was affected by this change.
In order for your control to function properly, you will need to make some code changes to the control implementation (.CPP) files.
static const OLECHAR BASED_CODE _szLicString[] =
OLESTR("Licensed Control Copyright (c) 1994-1995 My Corporation");
USES_CONVERSION;
TCHAR szMyString[] = _T("Licensed Control Copyright (c)
1994-1995 My Corporation"); //a multi-byte string
BSTR strWide = SysAllocString(T2OLE(szMyString));
The USES_CONVERSION macro and the T2OLE macro are described in Technical Note 59, Using MFC MBCS/Unicode Conversion Macros. These macros simplify calling functions that require conversion between Unicode and MBCS, particularly OLE API functions such as SysAllocString.
See Also Create a Program with the MFC ActiveX ControlWizard