File: ...\Samples\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
В | Copy Code |
---|---|
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.
В | Copy Code |
---|---|
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
В | Copy Code |
---|---|
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.
В | Copy Code |
---|---|
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.
В | Copy Code |
---|---|
DIMENSION THISFORM.aForms[nInstance + 1] |