Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Addition to 'appropriate license' bug
Message
 
 
To
20/02/2003 08:29:25
Marco Beuk
Innovero Software Solutions
The Hague, Netherlands
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00755450
Message ID:
00755464
Views:
9
Marco,

Sorry to disappoint you but you're using exactly solution from the article you reference. Maybe I'm missing somthing but the only difference is that you wrap it into another class. Why do you need that? W/o that wrapper code became quite simple.
PUBLIC o
o=CREATEOBJECT([mx_comm])

* Class to handle serial communications
DEFINE CLASS mx_Comm AS Form
	ADD OBJECT oMSComm AS MSComm 
	Visible = .F.
ENDDEFINE

DEFINE class msComm AS OleControl
	OleClass = "MSCOMMLib.MSComm.1"	
ENDDEFINE
>For the archives.
>In addition to the Knowledge Base Article - 192693
>http://support.microsoft.com/support/kb/articles/Q192/6/93.ASP
>i found the following solution.
>
>Creating a microsoft activex control at runtime from within a class other then a form.
>
>*\ corrected code from Message ID: 587009
>PUBLIC o
>o=CREATEOBJECT([mx_comm])
>
>* Class to handle serial communications
>DEFINE CLASS mx_Comm AS Container
>*!* ADD OBJECT oMSComm AS MSComm // does not work
>
>oForm = NULL
>oMSComm = NULL
>
>FUNCTION Init
>WITH This
> .oForm = CREATEOBJECT( 'Form' )
> *\ The form is default not visible
> *\ You could use a variable to hold the form instead of a property.
> *\ I rather use the property to avoid bangling object references
> *\ because the form will not release before you set oMSComm to .NULL.
> .oForm.AddObject( 'msComm', 'msComm' ) &&\ msComm defined below
> .oMSComm = .oForm.msComm
>ENDWITH
>ENDFUNC
>
>FUNCTION Destroy
> This.oMSComm = NULL
> *\ Now i'm seartain the form will release.
> *\ When you used a variable to hold the form,
> *\ the bangling form should be released automatically.
> This.oForm = NULL
>ENDFUNC
>
>ENDDEFINE
>
>DEFINE class msComm AS OleControl
> OleClass = "MSCOMMLib.MSComm.1"
>ENDDEFINE
>
>When you try to create the msComm class with CREATEOBJECT or to add the control with AddObject from within the mx_Comm class you will get the error 'Object class is invalid for this container'.
>It seems that only a form can contain such an object. So, in the above code of the Init i create a (dummy)form as a container for the msComm class and then take a reference to that object.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform