zoukankan      html  css  js  c++  java
  • Delphi主从窗体调用的实现

    用delphi来制作一些客户端小工具还是比较方便的。我们通常在做一个软件的时候,首先要考虑的是窗体布局和窗体之间的互相调用问题。下面就是主从窗体的实施步骤:
    第一步,打开【Delphi7】,新建一个Delphi工程,新建一个空白窗体命名为:【MainActivedForm】。
    然后重写构造函数:
    代码如下:
    interface

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

    type
      TMainActivedForm = class(TForm)

      private
          FAsChild: Boolean;
        { Private declarations }
      public
        { Public declarations }
        FTempParent: TWinControl;
        constructor Create(AOwner: TComponent); overload; override;
        constructor Create(AOwner: TComponent; AParent: TWinControl); reintroduce; overload;
      end;

    var
      MainActivedForm: TMainActivedForm;

    implementation

    {$R *.dfm}
     constructor TMainActivedForm.Create(AOwner: TComponent);
    begin
      FAsChild := False;
      inherited Create(AOwner);
    end;

    constructor TMainActivedForm.Create(AOwner: TComponent; AParent: TWinControl);
    begin
      self.BorderStyle := bsnone;
      self.Align := alclient;

      FAsChild := True;
      FTempParent := aParent;
     
      inherited Create(AOwner);
      setparent(AParent);
    end;
    end.

    新建一个子窗体,窗体的名称是【JXConfigForm】,窗体的基类设置为  TJXConfigForm = class(TMainActivedForm)。

    然后新建主窗体,并添加【MainActivedForm】的单元引用。

    在主窗体上拖一个TbsSkinPanel控件,命名为【bsSkinPanel2】。

    在主窗体中声明一个全局变量【aPnParent:TbsSkinPanel;】。

    创建主窗体的FormCreate事件,事件代码如下:
    procedure TMainForm.FormCreate(Sender: TObject);
    begin
    aPnParent := bsSkinPanel2;
     perform(WM_SIZE,SIZE_MAXIMIZED,0);
    end;

    在主窗体上放置一个按钮【bsSkinSpeedButton5】,添加按钮事件函数:
    procedure TMainForm.bsSkinSpeedButton5Click(Sender: TObject);
    begin
    //调出页面
      if MainActivedForm <> nil then
        begin
          MainActivedForm.Free;
        end;
      MainActivedForm := TJXConfigForm.Create(application, apnParent);
      MainActivedForm.show;
    end;

    这样,主从窗体的调用就完成了。

  • 相关阅读:
    用友U8 | 【存货管理】提示用户***正在记账,不允许并发。
    用友U8 | 怎么准确查找【采购入库单】、【采购发票】,对应的凭证号?
    用友U8 | 中途启用序列号管理,该怎么操作?
    Excel:提取身份证号中的性别
    给jupyter 添加代码自动补全功能
    SQL函数之:截断字符串
    解决Maven子项目提示 ‘parent.relativePath‘ of POM
    公共NTP资源汇总
    iperf3的使用
    ZeroTier的使用
  • 原文地址:https://www.cnblogs.com/wxf82610/p/2494630.html
Copyright © 2011-2022 走看看