Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Prevent opening a form if it's already opened.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00557131
Message ID:
00557164
Vues:
19
Hi!

First of all, do not use the variable created with name that match to form name. This variable is usable only in design-time mode for debugging purposes to quickly view the properties and objects of the form. In run-time mode this variable is nto reliable for referencing forms, do not use it in the code in the future.

You can use the _Screen.Forms collection to check if some particular form is opened:
* form class load event
if this.lOnlyOneInstanse && custom flag property, set it to .T. if form could be opned only once
  for i=1 to _Screen.FormCount && loop through all opened forms
    if _Screen.Forms(i).Name == this.Name && check if this form name match to any opened form name
      nodefault && prevent this form from loading
      _Screen.Forms(i).Show() && show the instanse of the form with this name that is already opened
      return .F. && do not continue any more in this instanse of the object
    endif
  endfor
endif
HTH.

>I know there has to be a standard way to do this. Within my app I launch forms from menus, from command buttons within other forms, and by double-clicking areas of forms, all using the DO FORM command. I am using the following code in the LOAD event of some of my forms to prevent creating a new instance of the form if it already exists:
>
>IF TYPE("Reportselect") = "O" and !ISNULL(Reportselect)
> Reportselect.Show()
> RETURN .F.
>ENDIF
>
>Of course "Reportselect" is the name of this particular form. How can I use a generic version of this code in the base class for my forms.
>
>
>Thank you kindly for your help.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform