Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing a form from a menu - newbie question
Message
De
21/09/2004 07:47:28
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00944466
Message ID:
00944485
Vues:
21
This message has been marked as the solution to the initial question of the thread.
Partially :)
I misread your question's text as .visible=.t. and thus used 'Show window'.

Hide window gForm

is what's you're looking for,no? Do not use gform.visible line at all. ie:

if wexist('gform') and wvisible('gform')
hide window gForm
endif


gForm in wexist(), wvisible(), wontop()... come from the name property of your form. If you're giving unique names to your forms you could track window names that way. However forms are not instantiated the same way depending on how you call them. ie: If you don't change default form.name property Form1:

do form myForm
do form myForm

Creates 2 forms with window names both as Form1.

wexist('Form1') returns .t. but form1.visible errors. myForm.Visible = .t. activates the first one in zorder (version and environment based - latter might not work always).

your Gform used in name clause sounds to be gone out of scope. You then might find your form through _screen.forms, _vfp.objects collection. ie:
for ix=1 to _screen.formcount
 if lower(_screen.forms(m.ix).name) == 'gform'
    _screen.forms(m.ix).visible = .F.
 endif
endfor
With unique form names that would work. If names are not unique all forms with same name property would be set to visible=.f.
Cetin




>cetin,
>
>thanks for the reply but it is still not clear. if i change my code to this, i still get an error:
>
>? wexist('gform') &&returns .t.
>show window gform
>gform.visible = .f.
>
>however your "show window" hint led me to "activate window" if i use this code, it works now:
>
>? wexist('gform') &&returns .t.
>activate window gform
>gform.visible = .f.
>
>is that okay?
>
>n.
>
>
>>>i have a menu option with two lines of code
>>>
>>>? wexist('gform') &&returns .t.
>>>gform.visible = .f. &&returns error "object gform is not found"
>>>
>>>not sure why that second line does not work if the form exists. how do i manipulate the form properties from within the menu? when i ran the form i am using "do form gform name gform"
>>>
>>>thanks,
>>>
>>>n.
>>
>>Nancy,
>>2 parts.
>>1) wexist('gform') is not a verifier for gform is there as an object.
>>
>>? wexist('gform') &&returns .t.
>>show window gform
>>
>>2) If you use do form with name clause then be sure the 'name' is in scope later when it's called. It's like any other variable and has the same scoping rules.
>>
>>public gForm
>>do form name gForm
>>
>>would make it work BUT public variables are not suggested. Create a single custom object on your app on entry and save things that should persist there.
>>
>>When you use that also change your code to:
>>
>>if type('gForm.Visible')='L'
>> gForm.Visible = .f.
>>endif
>>
>>PS: You might need extra checks if it's a form.
>>Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform