Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Form reference in run-time
Message
 
À
11/11/1998 01:49:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00155075
Message ID:
00156533
Vues:
24
>> From where are you trying to reference the form? Is it in a menu. on a
>> program, or from a method of some object inside the form itself?
>
>I tried to reference a form from another form, for instance. Both forms are not in a same formset.
>In another case I tried to reference a form from main menu.
>I came to decision,that the variable, by which I reference a form, must be declared PUBLIC first.
>Example -
>PUBLIC myform && declaring
>DO FORM anyform NAME myform && starting form
>myform.caption='Bla-bla' && referencing form
>
>Sergey
>reware@cafe.redcom.ru

Sergey,
That is one solution, but it has major limitations. What if the user tries to launch another instance of that form? Public variables are not a good thing.

Another approach is to create a non-visible object whose job is to launch and track forms. This object has a couple of methods in it named LaunchForm, RegisterForm, and RemoveForm. Your start up program would create the object;

* Startup
PRIVATE oForms
* CReate the form mngr
oForms = CReateObject("YourFormLauncherClass")
* Launch the menu
DO Whatever.mpr

READ EVENTS

The menu opions for a form would;

oApp.LaunchForm("TheFormYouWant")

The RegisterForm method would be called by the Form class in its Activate event and the RemoveForm would be called from the Form class's Destroy event.

For an example of this approach look at the TasTraders sample that comes with VFP.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform