如何在一个窗体中嵌入另一个窗体。

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;

事件触发(在FORM2中来响应FORM1的事件)
procedure TForm2.Button1Click(Sender: TObject);
begin
  if self.FOwnerForm.ClassType = TForm1 then
  begin
    showmessage('a');
  end;
end;
展开阅读全文

没有更多推荐了,返回首页