放一个空的pagecontrol在form上,使其充满客户区。
然后每打开一个文件增加一个tab
var
temptab:ttabsheet;
begin
temptab:=ttabsheet.create(pagecontrol1);
temptab.pagecontrol:=pagecontrol1;
temptab.caption:=文件名;
.....
end;
procedure TfrmMain.CheckChildren(force:boolean);
var
iLoop:integer;
begin
if((ChildList.Count = MDIChildCount) and (not force))
then exit;
tbcWIndows.Tabs.BeginUpdate;
try
tbcWindows.Tabs.Clear;
ChildList.Clear;
for iLoop := 0 to MDIChildCount - 1 do
begin
tbcWIndows.Tabs.Add((MDIChildren[iLoop]).Caption);
ChildList.Add(IntToStr((MDIChildren[iLoop]).Tag));
end;
for iLoop := 0 to MDIChildCount - 1 do
begin
if(MDIChildren[iLoop] = ActiveMDIChild) then
begin
tbcWindows.TabIndex := iLoop;
break;
end;
end;
finally
tbcWindows.Tabs.EndUpdate;
end;
end;
procedure TfrmMain.tbcWindowsChange(Sender: TObject);
var
tagIndex :integer;
begin
if(tbcWindows.Tabs.Count = 0)
then exit;
procedure TfrmMain.ShowSelectedChild(TagIndex:integer);
var
I:integer;
begin
if ActiveMDIChild <> nil then
begin
if(ActiveMDIChild.Tag = tagIndex) then exit;
for I := MDIChildCount - 1 downto 0 do
begin
if(MDIChildren.Tag = tagIndex) then
begin
MDIChildren.Show;
break;
end;
end;
end;
end;