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 existsIf 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().
>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 >>