各位大虾帮个忙,我最近学习写个软件,突然想起个问题不知怎样实现,还请各位大虾指点下
例如:
 在Form1中放Panel1控件,新建Form2
 然后怎样在编译后,运行时Form2就在Panel1中。谢谢

解决方案 »

  1.   

    ChildForm.Visible := False;
      ChildForm.BorderStyle := bsNone;
      ChildForm.SetBounds(0, 0, ParentControl.Width, ParentControl.Height);  Windows.SetParent(ChildForm.Handle, ParentControl.Handle);
      ChildForm.Visible := True;
      

  2.   

    procedure TForm1.FormActivate(Sender: TObject);
    var
      aForm2: TForm2;
    begin
      aForm2 := TForm2.Create(self);
      Form2.Parent := Panel1;
      Form2.Left := 0;
      Form2.Top := 0;
      Form2.Visible := true;
    end楼上的方法也可以,嘿嘿
    Windows.SetParent(ChildForm.Handle, ParentControl.Handle); //ChildForm 为FORM2       
                                                               //ParentControl 为 Panel1