我给你我的做法吧,不正确请大家指正,本人是老菜鸟,不过幸好用过这个。
procedure Tmain.OpenForm(cap:string;FormClass: TFormClass;
fm:Tform;
PageC:TRZPageControl);
var
NewPage: TRZTabSheet;
i : integer;
isop :boolean;
www :TRect;
begin
application.CreateForm(FormClass,fm);
创建窗体
NewPage := TRZTabSheet.Create(PageC);创建TabSheet
NewPage.PageControl := PageC;
NewPage.Caption :=cap;
fm.Caption:=cap;
PageC.ActivePage := NewPage;
www:=NewPage.BoundsRect;
fm.Dock(NewPage,www);
fm.Parent:=NewPage;
fm.Align:=alclient;
fm.show;
end
调用执行
openform(fcaption,Tygxx_frm,ygxx_frm,PageControl1);
fcaption:新打开窗口的caption
ygxx_frm:新打开窗口的name
PageControl1:这个知道吧,放一个PageControl1,(我用的是RzPageControl1)
下面双击关闭窗口
procedure TMAIN.PageControl1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var i:integer;
begin
// 双击删除当前页面
if (Button = mbLeft) and (ssDouble in Shift) then
begin
for i:=0 to screen.FormCount -1do
begin
if screen.Forms.Caption=PageControl1.ActivePage.Caption then
screen.Forms.Close;
end;
(Sender as TRZPageControl).ActivePage.Free;
end;