Home · Register · Login · Contact

Using ActiveX controls in C++


If you are a Windows developer using Visual C++ and would like to incorporate ActiveX components in an application, this tutorial has been designed to show you the proper steps for including these components.
  1. Start a new Visual C++ project. Select New from the Project Menu. This launches the dialog shown. Choose a location and a project name and click OK. A project wizard will guide you through the remainder of the application setup. Here are a few tips:

    1. Be sure to check the ActiveX Controls box.
    2. Share the MFC Library as a shared DLL.
    3. Let the Visual C++ AppWizard generate your classes for the project.
    4. Let the Visual C++ AppWizard generate your skeleton project.

    vc_new.jpg

  2. Next you must add ActiveX components to your Visual C++ project. In the Project Menu, choose "Add To Project" and "Components and Controls." Double-click the "Registered ActiveX Controls" directory. Select the component(s) that you wish to add by double-clicking or clicking the Insert button. The Component Wizard will build your header files for the component(s) that you have inserted. NOTE: Since Global Majic Software uses some standard C++ classes, you may see some extra classes listed. Build these also.
  3. Now you must set the properties for your ActiveX component. There are two (2) ways to get to properties pages in VC++. If you right mouse-click the component, you get a popup menu. The Properties item on this menu is VC++'s implementation of property pages. We developed a different mechanism which allows the user to watch changes when they are made (as opposed to pressing OK or Apply). To get to OUR property pages, follow the Object item and select Properties. These property pages allow you to configure the control's settings to your desired appearance.

    vc_props.jpg

  4. To set properties or handle events in code, you must add a member variable for the ActiveX component. Select "ClassWizard..." from the View menu. Select the "Member Variables" tab. The component will appear in the Control IDs column. Click the appropriate Control ID and then click the Add Variable button. Set the member variables name. The category will be "Control" and the Type will be the class name that you added in Step 2. Click OK. Now the Type and Member columns will be filled in. Click OK to apply the changes. NOTE: VC++ will automatically make the necessary changes in your header (.h) and implementation (.cpp) files.

    vc_mem1.jpg

  5. Now you can add your code to the project to interact with the ActiveX component. If you are not sure how to do this, all Global Majic Software ActiveX components come with sample code which can be downloaded from the Samples section of this site. Also, the documentation will address the syntax that you need to use when communicating with the ActiveX component's properties and methods.

Recently Visited Products

Recently Visited Pages