给你一个函数,我是在PageControl中显示的在Form上放一个cxPageControl 所有的Form 都显示在sheet 上,如果Form 已经存在则将它调到到最前面我正在用,非常好用兴趣和我联系QQ:14564807procedure TMainForm.ShowForm_Tab(FormClass: TFormClass;
form:Tform;
Flag:string);
//窗口融合 function GetFlag(Flag:string):Boolean;
var x,u: Integer;
begin
Result:=False;
for x := 0 to pgc.ControlCount - 1do
if pgc.Controls[x] is TcxTabSheet then
for u := 0 to TcxTabSheet(pgc.Controls[x]).ControlCount - 1do
if (TcxTabSheet(pgc.Controls[x]).Controls is TForm) and (TForm(TcxTabSheet(pgc.Controls[x]).Controls).Name=Flag) then
begin
Result:=True;
Break;
end;
end;
var i:Integer;
begin
Form := FormClass.Create(Application);
form.Color:=RGB(255,255,255);
if not GetFlag(Flag) then
begin
Form.Name:=Flag;
tabsheet:=TcxTabSheet.Create(nil);
Tabsheet.ParentColor:=True;
Tabsheet.Name:=Flag+'1';
Tabsheet.Caption:=Form.Caption;
Tabsheet.PageControl:=PGC;
pgc.ActivePage:=Tabsheet;
Form.Parent:=Tabsheet;
Form.Align:=alClient;
Form.BorderStyle:=bsNone;
Form.Show;
end else
begin
For i:=0 to pgc.PageCount-1do
if pgc.Pages.Name=Flag+'1' then
begin
pgc.Pages.TabVisible:=True;
pgc.ActivePage:=pgc.Pages;
Exit;
end;
end;
end;
调用试例procedure TMainForm.CGGL_ActionExecute(Sender: TObject);
begin
ShowForm_Tab(TCGGL_Frm,CGGL_Frm,'CGGL_Frm');
end;