How to embed another form in a form.

xiaoxiao2021-03-06  40

Form1

Uses unit2;

Procedure TFORM1.FormCreate (Sender: TOBJECT);

Begin

Form2: = TFORM2.CREATE (Panel, Self);

Form2.borderstyle: = bsnone;

Form2.windowState: = wsmaximized;

Form2.parent: = panel;

Form2.show;

END;

Form2

Uses unit1;

Private

FOWNERFORM: TFORM;

END;

Constructor Create (Aowner: Tcomponent; Ownerform: TForm); Reintroduce;

Constructor TFORM2.CREATE (Aowner: Tcomponent; Ownerform: TFORM);

Begin

Inherited Create (Aowner);

FOWNERFORM: = OwnerForm;

END;

Event trigger (in Form2 to respond to Form1 events)

Procedure TFORM2.BUTTON1CLICK (Sender: TOBJECT);

Begin

IF self.fownerform.classtype = tform1 Then

Begin

ShowMessage ('a');

END;

END;

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

New Post(0)