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

delphiTcxPageControl动态嵌入窗体

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
type
  TMyForm_test = class(TForm)
    cxpgcntrl1: TcxPageControl;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

type
  Applicationclass = class(TObject)
    class procedure addforms(Form: TForm);
    class function returnTcxPageControl: TcxPageControl;
    class procedure addMDIChild(MDIChildFormClass: TFormClass; var Reference; MenuName: string; midform: TFormClass);
  end;

var
  MyForm_test: TMyForm_test;

implementation

uses
  UnitTest123;

{$R *.dfm}

procedure TMyForm_test.FormCreate(Sender: TObject);
var
  temp: TFormTest123;
begin
  temp := TFormTest123.Create(nil);
  temp.Caption := '测试下';
  Applicationclass.addMDIChild(TFormTest123,temp,temp.Caption,TFormTest123);
end;

class procedure Applicationclass.addforms(Form: TForm);
var
  Sheet: TCXTabSheet;
begin
  Sheet := TCXTabSheet.Create(returnTcxPageControl);
  Sheet.font.size := 14;
  Sheet.font.Name := 'MS Sans Serif';
  Sheet.font.Style := [];
  Sheet.caption := Form.caption;
  Sheet.handles := Form.Handle;
  Sheet.Pform := Form;
  Sheet.PageControl := returnTcxPageControl;
  Sheet.ImageIndex := 0;
  Sheet.Tag := 2;
  Form.Parent := Sheet;
  Applicationclass.returnTcxPageControl.activePage := Sheet;
end;

class function Applicationclass.returnTcxPageControl: TcxPageControl;
begin
  result := MyForm_test.cxpgcntrl1;
end;

class procedure Applicationclass.addMDIChild(MDIChildFormClass: TFormClass; var Reference; MenuName: string; midform: TFormClass);
var
  MDIChildForm: TForm;
  I: Integer;
  WHandle: HWnd;
  Step: Integer;
begin
  with Application.MainForm do
  begin
    LockWindowUpdate(GetDeskTopWindow);
    try
      Screen.Cursor := crHourglass;
    except
      LockWindowUpdate(0);
      Screen.Cursor := crDefault;
      Application.ShowException(Exception(ExceptObject));
      Abort;
    end;
    try
      MDIChildForm := TForm(Reference);
      MDIChildForm.Parent := returnTcxPageControl;
      MDIChildForm.WindowState := wsMaximized;

      MDIChildForm.BorderIcons := [biMinimize, biMaximize];
      Applicationclass.addforms(MDIChildForm);
      MDIChildForm.Visible := true;
    finally
      Screen.Cursor := crDefault;
      LockWindowUpdate(0);
    end;
  end;
end;

 


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Delphi实现Ftp客户端下载(支持断点续传,多线程传输)发布时间:2022-07-18
下一篇:
Delphi连接sqlite方法总结发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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