LOCAL lnMenuNum, ; lAllowInstance, ; lcFormName lAllowInstance=thisform.allowinstance() if lAllowInstance *-- Add form's caption to the menu thisform.AddToMenu() else lcFormName = thisform.Name ACTIVATE Window &lcFormName && if already exist , just switch to it endif return lAllowInstanceBase form has property nInstancesAllowed for the number of allowed instances (default=1).
LOCAL lnNumberAllowed,; lnCount,; lnTally,; lcSCX,; llOK store 0 to lnCount,lnTally lnNumberAllowed=thisform.nInstancesAllowed ** Fetch the SCX file of this formset (or form) lcSCX=sys(1271,THIS) llok=.t. lnNumberAllowed=int(lnNumberAllowed) for lncount=1 to _Screen.FormCount if UPPER(_screen.forms(lncount).BaseClass)='FORM' if sys(1271,_screen.forms(lncount))=lcSCX ; and thisform.name=_screen.forms(lncount).name lntally=lntally+1 endif endif endfor if lnTally>thNumberAllowed *optional * =messagebox('Only'; * +alltrim(str(lnNumberAllowed)); * +' instance(s) is(are) permitted.',16,; * 'Limited Instance Form') llok=.f. endif return llokAlso it uses form's AddToMenu method: