Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Blocking multiple copies of a form
Message
 
À
19/12/1997 23:41:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00067335
Message ID:
00068048
Vues:
34
>>>>>Each time I select a form from my application's menu, a copy (or additional copy) is displayed on my screen. My menu commands for each form in the system look like "do form FormName"
>>>>>
>>>>>Instead, I want a form selection from the menu to set the focus to the running copy (if a copy is currently running), or to start a new copy of the particular form if it is not currently running. I don't want two copies of the same form running at the same time. How do I accomplish this?
>>>>>
>>>>>Bob Cassady
>>>
>>>
>>>>In order to do that you must first check if your form is not already on screen. You can do that by scanning the _SCREEN.Forms collection.
>>>>
>>>>Vlad
>>>>
>>>
>>>
>>>Great approach Vlad. Thanks, it works fine.
>>>
>>>The only outstanding problem I have now is figuring out how to programatically make MyForm the active form when MyForm is selected from the menu, is already on the screen, but is not currently the active form.
>>>
>>>Bob
>>
>>LOCAL oForm
>>FOR EACH oForm IN _SCREEN.Forms
>> IF oForm.Name == "MyForm"
>> EXIT
>> ENDIF
>>ENDFOR
>>oForm.Activate()
>>
>>Vlad
>
>
>I wish that my computer could respond as fast as you do.
>
>Not only do I have an answer to my problem, but also a concept that I was missing.
>
>Thanks again
>
>Bob
>
>..............
>
>I couldn't actually get your code to work, but the following (based on your ideas) does work.
>
>function OneForm(tcFormName)
>****************************
>for i = 1 to _SCREEN.formcount
> if trim(upper(_SCREEN.forms(i).name)) == trim(upper(tcFormName))
> _SCREEN.forms(i).windowstate = 0 && in case the form is minimized
> _SCREEN.forms(i).Show()
> return
> endif
>endfor
>
>do form &tcFormName
>
>endfunc
>
>Bob

Just as a further note, I don't use _SCREEN as I use a top-level form but the concept is the same. I have an array of form objects that is sized each time a user requests a form from a menu. The application owner only wants one of any form shown at a time so the array is checked each time a form is called for. If it's already in the array, I just use a .Show() to bring it to the front. I'm not sure why you need to issue another do form command as I would think that .Show() would work just fine.

Steve
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform