procedure Ts.FormCreate(Sender: TObject);
begin
AdvToolBarPager1.ActivePageIndex := 0; //首先动态加载一个页面
AdvToolBarPager1Change(AdvToolBarPager1);
end;
procedure Ts.AdvToolBarPager1Change(Sender: TObject);
var
TabIndex: Integer;
cClass: TClass;
PageControl: TAdvToolBarPager;
frameName: string;
begin
PageControl := Sender as TAdvToolBarPager; //赋值
TabIndex := PageControl.ActivePageIndex; //赋值
if PageControl.ActivePage.Tag <> 0 then Exit; //如果已经存在,则不在重新加载
cClass := GetClass('TFrame' + IntToStr(TabIndex + 1)); //加载
if not Assigned(cClass) then Exit;
frame := TComponentClass(cClass).Create(Self) as TFrame;
if not Assigned(frame) then Exit;
Frame.Parent := Self; //动态加载
frame.align := alclient;
PageControl.ActivePage.Tag := -1; //给Tag 属性赋值,以便不进行重复操作
{initialization frame}
PostMessage(frame.Handle, WM_INITFRAME, 0, 0);
end;