我以前也遇到过此类问题而且,基本得到了比较全面的方法!
方法一:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
//在Form2的OnShow事件中加入对Form1的创建,同时指定Form1的parent.并且对
//left,Top,Height,Width赋值,防止其显示超出范围
procedure TForm2.FormShow(Sender: TObject);
begin
Application.CreateForm(TForm1, Form1);
Form1.Parent:=Panel1;
Form1.Left:=2;
Form1.Top:=3;
Form1.Height:=100;
Form1.Width:=150;
Form1.Show;
end;
方法二:
unit weichenggong1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Bevel1: TBevel;
Button1: TButton;
Panel1: TPanel;
Panel2: TPanel;
procedure ShowForm(FormClass: TFormClass; Form: TForm; FPal: TPanel);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.DFM}
procedure TForm1.ShowForm(FormClass: TFormClass; Form: TForm; FPal: TPanel); //窗口融合
begin
if Form = nil then
Form := FormClass.Create(nil);
FPal.DockSite := True;
with Form do
begin
DockSite := True;
DragKind := DkDock;
Align := alClient;
HostDockSite := FPal;
Show;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TForm1.ShowForm(TForm2, Form2, Panel1);
TForm1.ShowForm(TForm3, Form3, Panel2);
end;
end.
还有其他的方法,可以去下面的地方看看:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1046558
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1241687
如果觉得有收获就给点分吧,哥们穷的可怜~!哈……