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;
  • 相关阅读:
    Redis与Redis 伪集群环境的搭建
    github的基本使用
    使用七牛云存储图片或文件并回显
    阿里云搭建wordpress博客教程
    判断是否同一天 同一月
    Python学习笔记之 并发编程
    Python学习笔记之 日志模块logging使用详解
    Python学习笔记之 网络编程(socket套接字编程)
    Python实现TCP文件传输
    实例:Python实现聊天室
  • 原文地址:https://www.cnblogs.com/yangxuming/p/7852543.html
Copyright © 2011-2022 走看看