File: ...\Samples\Vfp98\Solution\Forms\Launch.scx
This sample demonstrates running multiple instances of a form. aForms
is an array property of the form that launches the multiple instances. The following code is associated with the Click event of the command button that launches multiple forms:
Get the number of the last element in the array
nInstance = ALEN(THISFORM.aForms)
Determine the Top and Left Properties to cascade the new forms. These settings are passed as parameters when the form instances are launched.
IF nInstance > 1 AND ;
TYPE('THISFORM.aForms[nInstance -1]') = 'O'
nFormTop = THISFORM.aForms[nInstance -1].Top + 1
nFormLeft = THISFORM.aForms[nInstance -1].Left + 1
ELSE
nFormTop = 1
nFormLeft = 1
ENDIF
Set the caption to reflect the instance number
cFormCaption = "Instance" + ALLTRIM(STR(nInstance))
Run the form and assign the object variable to the array element. The Linked keyword indicates that all instances will be released when the array is released. Without LINKED
, the multiple instance forms would persist after the array is released.
DO FORM Multi NAME THISFORM.aForms[nInstance] WITH ;
nFormTop, nFormLeft, cFormCaption LINKED
Redimension the array so that more instances of the form can be launched.
DIMENSION THISFORM.aForms[nInstance + 1]