• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi中多标签页面的实现

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RzTabs, Menus;

type
  TFrmMain = class(TForm)
    RzPageControl1: TRzPageControl;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N11: TMenuItem;
    N21: TMenuItem;
    N31: TMenuItem;
    TabSheet1: TRzTabSheet;
    procedure N11Click(Sender: TObject);
    procedure N21Click(Sender: TObject);
    procedure N31Click(Sender: TObject);
    procedure RzPageControl1Close(Sender: TObject; var AllowClose: Boolean);
  private
    { Private declarations }
  public
    procedure ShowDockForm(FormClass: TFormClass; dockCtrl: TRzPageControl );

  end;

var
  FrmMain: TFrmMain;

implementation

uses
  Unit1;

{$R *.dfm}
{ TForm12 }

procedure TFrmMain.N11Click(Sender: TObject);
begin
  ShowDockForm(TForm1,RzPageControl1);
end;

//procedure TFrmMain.N21Click(Sender: TObject);
//begin
//  ShowDockForm(TForm2,RzPageControl1);
//end;
//
//procedure TFrmMain.N31Click(Sender: TObject);
//begin
//  ShowDockForm(TForm3,RzPageControl1);
//end;

procedure TFrmMain.RzPageControl1Close(Sender: TObject;
  var AllowClose: Boolean);
begin
  AllowClose :=  RzPageControl1.ActivePageIndex >0;
end;

procedure TFrmMain.ShowDockForm(FormClass: TFormClass; dockCtrl: TRzPageControl);
  procedure ShowCaption(ParentCtrl: TWinControl; ACaption: string);
  begin
    if ParentCtrl is TRzTabSheet then
      TRzTabSheet(ParentCtrl).Caption := ACaption;
  end;

var
  i: Integer;
  TabCtrl: TRzTabSheet;
  Form: TForm;
begin
  Screen.Cursor := crHourGlass;
  try
    for i := 0 to Screen.CustomFormCount - 1 do
      if Screen.CustomForms[i] is FormClass then
      begin
        if (not(Screen.CustomForms[i]).Visible) then
          (Screen.CustomForms[i]).Visible := True;
        (Screen.CustomForms[i]).BringToFront;
        (Screen.CustomForms[i]).SetFocus;
        TabCtrl := TRzTabSheet(Screen.CustomForms[i].Parent);
        ShowCaption(TabCtrl, Screen.CustomForms[i].Caption);
        TRzPageControl(dockCtrl).ActivePageIndex := TabCtrl.PageIndex;
        exit;
      end;

    TabCtrl := TRzTabSheet.Create(dockCtrl); // dockCtrl
    TabCtrl.PageControl := TRzPageControl(dockCtrl);
    TRzPageControl(dockCtrl).ActivePageIndex := TabCtrl.PageIndex;

    Form := FormClass.Create(TabCtrl);
    with Form do
      try
        ManualDock(TabCtrl);
        ShowCaption(TabCtrl, Caption);

        Show;
        Form.WindowState := wsMaximized;
        Form.Align := alClient;
      except
        Free;
      end;

  finally
    Screen.Cursor := crDefault;
  end;
end;

end.

http://blog.csdn.net/diligentcatrich/article/details/8281965


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap