Programming Tips - MFC: How do I use COM in Microsoft Visual C++ 6 ?

Date: 2005Jun3 Framework: MFC Language: C/C++ Keywords: COM, VC6 Warning: This is not about the current version of Visual C++ Q. MFC: How do I use COM in Microsoft Visual C++ 6 ? A. To create a COM object ---------------------- - File > New ... > Projects > MFC ActiveX ControlWizard (Do *not* select ATL COM AppWizard) - Use the wizard to generate the control and compile it. You should now have a registered .OCX file! - Click on bold name of the project in the explorer window (typically on the left) and to View > Class Wizard to add methods To add methods/properties ------------------------- - View > Class Wizard > Automation > Add Method - View > Class Wizard > Automation > Add Property To use a COM object ------------------- - Project > Add to project > Components and Controls > Registered ActiveX Controls and insert into your project - You should now have a C++ class that wraps the COM object but you can not just use this class any way you want. You should place the control in a dialog (just you would do with an EditBox) and use from there. If the control has no visual use, you can hide it.