Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Holding the name of a control as a string?
Message
De
05/03/2002 17:38:36
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00628023
Message ID:
00628743
Vues:
35
Chris,

You would do it right after your createobject()...this is the first place I found it, you would have to add a line below the other 2 places.
this.aForms[this.pOpenFormCount] = createobject(cFormToOpen)
this.topForm = this.aForms[this.pOpenFormCount]
In your other code (where you do a string comparison with oApp.topform), you would have to compare it to a property of the form, such as the name property:
if oApp.topForm.name = "frmCustomer" && I don't remember what name you had...
From this, it looks like the user can have multiple forms open. You have to change oApp.topform whenever the user switches between forms, but I guess you could do that within the gotfocus() of each form:
oApp.topForm = this  && you can use vartype to make sure oApp really exists
If the user has multiple forms open, this brings you back to square one...how to prevent the user from switching forms if a change has been made in the current form (my opinion is you shouldn't prevent this *grin*). You should be able to do this in lostfocus().

>>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?
Steve Gibson
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform