Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Addition to 'appropriate license' bug
Message
De
20/02/2003 09:44:41
Marco Beuk
Innovero Software Solutions
The Hague, Pays-Bas
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00755450
Message ID:
00755507
Vues:
22
Sergey,

As far as i can see the message i referenced is not a solution but a question for help. In that message mx_Comm is defined 'AS Container'.

Your solution is the most simple and effective.
In our situation we have a customclass based on another customclass wich is based on a custom-baseclass.
Redefining the upperclass to a form-baseclass would loose the inherited code of its parentclass. Redefining the parentclass is not an option.

>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform