zoukankan      html  css  js  c++  java
  • delphi TcxPageControl 动态嵌入窗体

    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;
  • 相关阅读:
    【第4题】 什么是https
    【第3题】 两个队列生成一个栈
    【第2题】 链表的逆置
    【第1题】 Pythonn内存管理以及垃圾回收机制
    tmunx error:invalid option: status-utf8 invalid option: utf8
    ubuntu install google-chrome-stable
    使用pyenv安装多个Python版本
    Linux命令行烧录树莓派镜像至SD卡
    freenode configuration sasl authentication in weechat
    尝试IRC & freenode
  • 原文地址:https://www.cnblogs.com/yangxuming/p/7852543.html
Copyright © 2011-2022 走看看