Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AddObject with an ActiveX control.
Message
From
15/07/1999 08:49:53
 
 
To
15/07/1999 07:48:53
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00241705
Message ID:
00241726
Views:
13
>How do I do to add an ActiveX control to _screen with the AddObject()?
>

I've never done this, but from the error returned by trying the obvious approach:

_screen.AddObject('oComm1','MSCOMMLIB.MSCOMM') && tries to add the MSComm control

I'd guess that if it can be done at all, you'd have to create a subclass using the OLEControl class; I couldn't get this to work, either, although I can add the class below trivially to a class instance derive from the Form class:
DEFINE CLASS MSComm AS OLEControl
   OLETypeAllowed = -2
   OLECLASS = 'MSCOMMLIB.MSCOMM'
ENDDEFINE

oForm = CREATEOBJ('Form')
oForm.AddObject('oComm','MSComm')
If you need to attach an ActiveX control to the main VFP Window for the application, in all probability you'll have to use a top-level window instead of _SCREEN, and then have all forms' ShowWindow set to 1 if they need to be treated as a child of the active top-level form rather than the default of 0. You can do an AddObject of a subclass of OLEControl to a top-level form, either visually using the Form Designer or programmatically.

If the ActiveX control didn't need to have a screen presense, like SysInfo or MSComm, you could use the VFP6 AddProperty method to add it to _screen, creating the instance of the control via CREATEOBJ() or NEWOBJECT():

_Screen.AddProperty('oComm')
_Screen.oComm = CREATEOBJ('MSCOMMLIB.MSCOMM')

You could then use a wrapper class and VFPCOM to tie VFP Code to the events using VFPCOM's BindEvents method.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform