Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Two classes with the same name of form
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00367864
Message ID:
00367916
Vues:
31
Your life would definately be easier if they didn't have the same name!

But if your stuck with the class names, you could also try the following. If you have Lib1.vcx and Lib2.vcx which both contain a class named 'cSomeForm', you could try the following code:
SET CLASSLIB to Lib1.vcx, Lib2.vcx ADDITIVE
LOCAL loForm1, loForm2

loForm1 = CREATEOBJECT("Lib1.cSomeForm")
loForm2 = CREATEOBJECT("Lib2.cSomeForm")
This should work as long as the class libray names are unique. If they are not, you can use SET CLASSLIB's ALIAS clause to make one unique.



>John,
>
>You'll have to resort to using NewObject() everywhere instead of CreateObject() for the two classes so you can specify the classlib. Otherwise VFP will instantiate the first one that it finds in the current loaded class environment and it's kind of hit or miss which one you'd get without a ton of work on your part. If you are deriving forms from these two and you DO FORM them you should be ok because internally VFP uses the classlib name.
>
>Your life would be easier if they didn't have the same name.
>
>>What happens when two different classes contain a form with the same name? I have a framework class that contains the form named 'frmStatusBar' and foxfire has a class that contains the same name for a form.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform