Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing a class in a form from another class
Message
De
09/08/1997 07:46:53
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00043412
Message ID:
00043860
Vues:
33
Jimn,

But it can be a source of confusion to have three (yes, three) names floating about for a form:

1) the name in the Name property;
2) the name of the form as it appears in the Project Manager window;
3) the name on the Name clause of Do Form.

Some other nomenclature would have been more helpful all around.

regards,
Jim N

.>>I have a class that is made up of a container and some labels. We will call it Example1.
>>
>>I instantiate this class with oExample1 = CREATEOBJECT("example1") at the beginning of my program. I then run a form with DO FORM. In the ini() method of the form, I ADDOBJECT("oExample1", "example1") this container class to the form.
>>
>>While the program is running, a timer object fires a method in another class that was also instantiated at the beginning of the program with oExample2 = CREATEOBJECT("Example2"). While this method is running, it updates the captions in the first class with oExample1.lblLabel.Caption = Testing". This update is not reflected in the Example1 class.
>>
>>My thought is that I have create two separate instances of Example1, so changeing the labels in oExample does not effect frmForm.oExample. If this is true, how do I go about writing to the object in the form from outside the form. I have tried _SCREEN.frmForm.oExample, frmForm.oExample, and _VFP.frmForm.oExample to no avail. The other question would be, am I going about this the wrong way?
>>
>>Thanks Ed
>Ed,
>
>You are correct that you are manipulating the wrong instance of your class. To manipulate the object inside of the fomr you need to address it there. You can use;
>
> _screen.ActiveForm.oExample1
>
>if the form is the currently active form. Beyond that you would need some kind mechanism for tracking the fomrs that have been launched.
>
>The other issue is that you are confusing the Name property of the form with the form object's name, they are not the same thing. To assign a name to the form object you need to use the NAME clause on teh DO FORM command, as in;
>
> DO FORM MyForm NAME MyForm LINKED
>
>the LINKED keeps the variable holding the form reference (MyForm) existance as long as the form is there.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform