JavaScript Editor js editor     Web development 

Main Page

You can create COM objects with the ActiveX Template Library provided with MicrosoftВ® Visual C++.

You create Microsoft ActiveX controls specific to Visual FoxPro as you would any similar control. Most C++ compilers allow you to create skeletons of the control, and they can be created with the Microsoft Visual Basic Control Creation Edition.

The following sections describe the steps for creating an ActiveX control with Microsoft Visual C++ 6.0 for use in Visual FoxPro.

To create a project for the ActiveX control

  1. Start Microsoft Visual C++.

  2. From the File menu, choose New.

  3. In the New dialog box, choose Project Workspace.

  4. In the New ProjectВ Workspace dialog box, specify a project name.

  5. In the Type list, choose OLE ControlWizard.

  6. Choose Create, and then follow the steps in the wizard.

When the wizard is finished, you can build the ActiveX control immediately. However, you will also need to define properties and methods for the control.

To add properties and methods to the ActiveX control

  1. From the View menu, choose ClassWizard.

  2. Choose the OLEAutomation tab.

  3. Choose Add Method or Add Property.

  4. Fill in the name, parameter, and other information required by the element you are creating, and then choose OK.

  5. Choose Edit Code to display the editor, and then enter the code that defines the property or method you are creating.

For example, to create a Version property that returns the .ocx file version as an integer (such as 101), you create the property with a return type of long, and add code similar to the following:

В Copy Code
#define VERSION 101

long CPyCtrl::GetVersion()
   // set the version number here
   return VERSION;

Because the version number is ordinarily read-only, you wouldn't create a SetVersion(В ) function.

See Also

JavaScript Editor js editor     Web development