Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you declare a FORM public?
Message
De
15/08/1997 14:26:24
Bob Lucas
The WordWare Agency
Alberta, Canada
 
 
À
14/08/1997 15:07:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00044717
Message ID:
00044999
Vues:
30
>I need to get access to a object this is in a FORM that is not active.


If one form needs to reference objects in another form (or forms) there are probably a few things you need to decide.

[1] Does my form need to know about all the forms that may be on the desktop (And if so, why?)

[2] Does my form have specific information to be accessed.

All forms that are currently active will have an entry in _screen.forms (accessed by _screen.forms[1] etc.) Chances are though, this is not particularly useful except when you want to close ALL forms.

Most application frameworks have standard functions to add each form to a global array property (oforms for instance) when a form is instantiated, and also to add a reference to the form to the Window menu item. The reverse occurs when the form is closed. This is all global stuff.

What I would consider a better object-oriented approach where one form needs to reference properties or objects on other forms is to pass to this form a reference or references to the forms that might be referenced. (Did that make sense). If it always only one form, then just pass a simple reference to the form. If it is more than one form you wish to communicate with, you can pass as the parameter an array of form references (or perhaps a linked list of forms).

The reason I suggest this is that now all of your object references, for objects on the current form and objects on another form use a common heirarchy. That is, a texbox value might be thisform.txtdata.value or on another form thisform.oform.txtdata.value.

If one form calls or instantiates another form, I almost always will pass the first form as the parameter to the second (toform) and then I save this parameter to a property on the second form --> thisform.oform = toform. (of course, in the release of this form I must do a thisform.oform = NULL!) Now I can access any property of the parent form with thisform.oform. If the parent needs to do some special functioning when the child form (assuming modal here for a moment) closes, I will set properties of the parent form and when the child closes the parent can check these properties to see what processing might be required. Everything is very neatly self contained.

One very critical advantage is if a second form has a private data session and it calls a method that belongs to an object on another form then the data session that is in force during the method call is the data session that belongs to the form of that object! This is why methods that are attached to a global application object sometimes return data into the wrong the datasession when called from within a form using a private data session!

Bob
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform