General Sub Form Switch

xiaoxiao2021-03-06  77

/ Universal sub-form switch

Procedure OpenForm (FormClass: TFormClass; VAR AFORM;

Aowner: tComponent = NIL);

VAR

i: integer;

Child: TForm;

Begin

For i: = 0 TO Screen.formcount -1 DO

IF screen.forms [i] .CLASSTYPE = FormClass THEN

Begin

Child: = Screen.Forms [i];

If child.windowstate = wsminimized then

Child.windowState: = WSNORMAL;

Child.bringtofront;

Child.setfocus;

TFORM (AFORM): = CHILD;

EXIT;

END;

Child: = TFORM (FormClass.newinstance);

TFORM (AFORM): = CHILD;

IF NOT Assigned (Aowner) THEN AOWNER: = Application;

Child.create (aowner);

END;

Use: OpenForm (TFORM1, FORM1);

转载请注明原文地址:https://www.9cbs.com/read-121543.html

New Post(0)