Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check if another form is open
Message
De
11/01/2006 10:04:48
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01085589
Message ID:
01085620
Vues:
16
>>>I want to be able to ascertain if another form is open, then transfer control to that form. It sounds easy but can't
>>
>>Tim
>>
>>Perhaps the following will help. It sees if a form is NOT open and opens it if not. A man of your calibre can easily tweak it to the reverse. :-)
>>
>>Terry
>>
>>
>>Function sysFormOpen
>>*___________________
>>find the syntax for this.
>>* Supplied with a form's name property, go thru list of
>>* open forms to see if that form is open.
>>* ____________________
>>LPARAMETER  tcFormName
>>LOCAL	   lnFormCount, llOpen, lnFormNo, lnOpenFormNo
>>
>>llOpen			= .F.
>>lnFormCount 		= _SCREEN.FormCount
>>lnOpenFormNo		= 0
>>If lnFormCount > 0
>>    lnFormNo 		= 1
>>    Do	WHILE	lnFormNo <= lnFormCount ;
>>	AND	not llOpen
>>      If ALLTRIM( LOWER( _SCREEN.Forms( lnFormNo).Name)) = ALLTRIM( LOWER( tcFormName))
>>	llOpen		= .T.
>>	lnOpenFormNo	= lnFormNo
>>      Else
>>	lnFormNo		= lnFormNo + 1
>>      Endif
>>    EndDo
>>Endif
>>
>>Return lnOpenFormNo	&& index of specified form
>>
>>Procedure sysOpenForm
>>*____________________
>>* If a named form is not already open, open it by physical name
>>* Else just ignore
>>* ________________
>>LPARAMETERS  tcFormName, tcPhysName, tcObjectName
>>LOCAL	    lnNoParms
>>
>>lnNoParms	= PARAMETERS()
>>If not sysFormOpen( tcFormName) > 0	&& If supplied form not already open
>>    If lnNoParms = 3		&& If want an object name with it too
>>	do FORM &tcPhysName Name &tcObjectName
>>    Else
>>	do FORM &tcPhysName
>>    Endif
>>Endif
>>
>What if the form is already open somewhere, does your code(which is nice) provide for switching to it rather then re-open it?

No, as the comments said, just ignore an open form. That would have been desirable but I was too lazy/pressed/unknowledgable to be bothered at the time of writing it.

I see. I'd interpreted your request as transfer control to that form if not already open (you just said see if it's open).

I guess you could refer to the other form's object or NAME property, and SetFocus to a control On that form.

e.g., something like (to replace the existing code):
    If lnNoParms = 3		&& If want an object name with it too
	&tcObjectName.Text1.SetFocus Name &tcObjectName
    Else
	&tcPhysName.Text1.SetFocus 
    Endif
Now, in debug locals window, there's a whole bunch of .Controls drill-down, if they can be used in code, if you don't know at run-time the name of the, say, first control on the object form.

Never done this so just speculating.

Or, as Peter says, use &Whichever.Show()

HTH

Terry
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform