Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Holding the name of a control as a string?
Message
 
À
05/03/2002 16:49:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00628023
Message ID:
00628731
Vues:
38
>What code do you use to launch a new form? If you something like the following, there is no need to evaluate:

This is the routine I use...
procedure mLaunchForm
lparameters cFormToOpen

* set class library if not already set
if "pogo_classes" $ set('classlib')
else
set classlib to pogo_classes additive
endif

* set value of pOpenFormCount to the number of columns in aForms
this.pOpenFormCount = alen(this.aForms, 1)

* set lnCount minus 1 for actual array locations that could hold forms
lnCount = this.pOpenFormCount - 1

* check if it's the first ever form
if this.pOpenFormCount = 1

* create and show the form
this.aForms[this.pOpenFormCount] = createobject(cFormToOpen)
this.aForms[this.pOpenFormCount].show()

* re-dimension the form to allow for new forms to be added
dimension this.aForms[this.pOpenFormCount + 1]

* increase the pOpenFormCount value
this.pOpenFormCount = this.pOpenFormCount + 1

* if first form already exists - check if form is alreadu open
else

for lnLoop = 1 to lnCount

* ignore any null or logical value arrays
if isnull(this.aForms[lnLoop]) or type('this.aForms[lnLoop]') = 'L'

else

* check for form name amongst the open forms
if this.aForms[lnLoop].name = (cFormToOpen)
this.lnFormFound = .t.

* form is found so exit after setting lnFormFound .t.
exit

else

* if form is not found
this.lnFormFound = .f.

endif
endif
		
endfor

* check value of lnFormFound
if this.lnFormFound

* form was found so zoom - show - refresh
zoom window (this.aForms[lnLoop].name) norm
this.aForms[lnLoop].show()
this.aForms[lnLoop].refresh()

else

* form wasn't found so it doesn't exist - create it

* loop used to find the first avaliable array location
for lnLoop = 1 to lnCount

* if null or logical is found - create the form
if isnull(this.aForms[lnLoop]) or type('this.aForms[lnLoop]') = 'L'
this.aForms[lnLoop] = createobject(cFormToOpen)
this.aForms[lnLoop].show()

else

* no spare locations - adding the form to the end
this.aForms[this.pOpenFormCount] = createobject(cFormToOpen)
this.aForms[this.pOpenFormCount].show()

endif

* form has been added so exit the loop
exit

endfor

* re-dimension the array so that new forms can be added
dimension this.aForms[this.pOpenFormCount + 1]

endif

endif

endproc

*	End of mLaunchForm procedure
Sorry it's so long but I don't know how then to refer to the form that is oApp.TopForm to get it to work with .queryunload?
Chris Maiden
Email
Web
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform