Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
This one has me baffled
Message
 
À
29/03/1998 23:52:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00088012
Message ID:
00088291
Vues:
24
>A menu option calls the procedure with a parameter (the form to launch mFormName):
>
>PROCEDURE LAUNCHFORM
>1 if wexist(mFormName)
>2 mCommand=mFormName+".Show"
>3 &mCommand
>4 else
>5 do form &mFormName
>6 endif
>RETURN
>
>which, to my simple mind should work.
>
>Lets say the form has not been launched and so does not exist in this instance of the app. Calling the code above correctly launches the else portion and launches the form.
>
>If I immediately call the procedure again, via a second call to the menu option, the code pukes at line 2 with the error "Object OUTGOING is not found". (OUTGOING being the value of mFormName). It has correctly identified that the window does exist - and it does because I can see it on the screen - but it ceases to exist in the sense that I can call its "Show" method.
>
>A LIST OBJECTS at this point confirms that the object does not exist ... or does it ? Or is a window not an object ?
>
>Gerry.
Gerry,

You are finding out why we need frameworks. First, yes the window has a name, but the window is not a VFP object it is a windows object. It has no method and it has very few properties. What you really want to do is get the variable that references the form and not the window. However your framework does not save the form references with the do form command, it just runs the form, VFP gives the form some name (God only knows waht) and you run along happily. Happily that is until you need to talk to that fomr adn you don't know its name.

Take a studied look at the TasTrade application that came with VFP. It launches forms in a similar but different way than you are. TasTrade has an object in memory that has a LaunchForm method. When a form is needed the oApp.LaunchForm() method is called passing the formname desired along with some other data. The oApp object does ot simply run the form, it also records the fomr in an array protery inside itself and in the additional columns it records other identifying information. One of the columns of the array is an object reference to the actual form object.

If you spedn a little time with TasTrade you will see exactly how that stuff is being done.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform