How to: Access ActiveX Controls and Objects
You can use any ActiveX control that is available on your computer. To use an ActiveX control, you add it to a form, then set its properties, write handlers for its events, or call its methods. You can add an ActiveX control to a form using the Form Controls toolbar or the, or by using code. For details about adding an ActiveX control in the Form Designer, see .
You can create an ActiveX control in code in much the same way you would create any Visual FoxPro control. However, before creating the control you must determine the name of the control's class library, which is stored in the Windows registry. If you have no other way to determine the class library name, use the Form Designer to create the control (as described in the previous section), and then get the control's OLEClass property.
ActiveX objects can be created directly with CREATEOBJECT( ), and don't require an instance of a form.
To create an ActiveX control in code
Callto create a form.
Call the new form'sto add the control, specifying olecontrol as the class. You must pass the control's class library name as the third parameter of the AddObject method.
For example, the following program creates a new form and adds a listview control to it:
oMyForm = CREATEOBJECT("form") oMyForm.AddObject("oleListview","olecontrol", ; "MSComctlLib.ListViewCtrl")
oMyForm.oleListview.Visible = .T. oMyForm.Show
Some ActiveX controls aren't designed primarily to be used interactively by a user. For example, a timer control doesn't support methods for user interaction. Even then, you can still create the control on a form because the control will usually make available a default visible component, such as an icon. Frequently you will not be able to change or resize the icon.
If you don't want your application to display the icon for non-interactive controls, you can hide the control by setting the Visible property of its OLE container control to false, or set its Left property to a negative value (such as –100) that moves it off the visible portion of the screen. Alternatively, you can place the control on a form that's never made visible (that is, for which the Show method is never called). In all cases, you can still call the control's methods as if the control were visible.