• 015.Delphi插件之QPlugins,FMX插件窗口


    内嵌FMX的插件窗口,效果还是很可以的。退出时,会报错,很诡异啊。

    主窗口代码如下

    unit Frm_Main;
    
    
    interface
    
    uses
      Winapi.Windows,
      Winapi.Messages,
      System.SysUtils,
      System.Variants,
      System.Classes,
      Vcl.Graphics,
      Vcl.Controls,
      Vcl.Forms,
      Vcl.Dialogs,
      qplugins_vcl_formsvc,
      qplugins_loader_lib,
      qstring,
      qplugins_base,
      qplugins,
      qplugins_params,
      qplugins_vcl_Messages,
      qplugins_formsvc,
      Vcl.StdCtrls;
    
    type
      TForm_Main = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form_Main: TForm_Main;
    
    implementation
    
    {$R *.dfm}
    
    // 按钮_FMX窗口
    procedure TForm_Main.Button1Click(Sender: TObject);
    var
      AFormService: IQFormService;
      AParam: IQParam;
    begin
      // 在这个路径查找服务
      if Supports(PluginsManager.ByPath('/Services/Docks/Forms/FMXForm'), IQFormService, AFormService) then
      begin
        // 模态显示窗口
        // 输出窗口信息
        ShowMessage(ServiceSource(AFormService as IQService));
        // 模态显示窗口
        AFormService.ShowModal(nil, nil);
      end;
    end;
    
    // 创建
    procedure TForm_Main.FormCreate(Sender: TObject);
    var
      APath: string;
    begin
      ReportMemoryLeaksOnShutdown := True;
      // 加载同目录的DLL插件
      APath := ExtractFilePath(Application.ExeName);
      PluginsManager.Loaders.Add(TQDLLLoader.Create(APath, '.dll'));
      // 启动
      PluginsManager.Start;
    end;
    
    end.

    FMX的DLL插件代码如下

    unit Frm_Fmx;
    
    
    interface
    
    uses
      System.SysUtils,
      System.Types,
      System.UITypes,
      System.Classes,
      System.Variants,
      FMX.Types,
      FMX.Controls,
      FMX.Forms,
      FMX.Graphics,
      FMX.Dialogs,
      FMX.Controls.Presentation,
      FMX.StdCtrls,
      FMX.Ani,
      FMX.Objects,
      QPlugins,
      qplugins_fmx_messages,
      qplugins_formsvc,
      qplugins_fmx_formsvc,
      FMX.Edit;
    
    type
      TForm_Fmx = class(TForm)
        Label1: TLabel;
        Panel1: TPanel;
        Image1: TImage;
        FloatAnimation1: TFloatAnimation;
        Edit1: TEdit;
        Edit2: TEdit;
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form_Fmx: TForm_Fmx;
    
    implementation
    
    {$R *.fmx}
    {
      procedure ShowFMXForm;
      begin
      // 创建窗口
      Form_Fmx := TForm_Fmx.Create(nil);
      FreeAndNil(Form_Fmx);
      end;
      exports ShowFMXForm; }
    
    initialization
    
    // 注册2个窗体服务
    RegisterFormService('/Services/Docks/Forms', 'FMXForm', TForm_Fmx, True);
    RegisterFormService('/Services/Docks/Forms', 'FMXDock', TForm_Fmx, False).Align := faLeftBottom;
    
    finalization
    
    // 注销
    UnregisterServices('/Services/Docks/Forms', ['FMXForm', 'FMXDock']);
    
    end.
  • 相关阅读:
    frp反向代理+内网穿透+ Metasploit渗透windows
    FRP实现内网穿透
    FRP 内网穿透工具
    通过代理实现在校园外使用校园网内的服务 (frp内网穿透)
    戴维斯双击
    pycharm2019,3.1版本的有效激活方法
    一键对centos7.6安装python3环境已经pip3
    在linux设置/etc/vimrc 将vim 中后缀.sh的文件 的前几行进行默认输入
    Postman Interceptor和postman更改id仍然无法使用的,从这里下载相同版本的postman和interceptor插件
    Postman Interceptor安装成功却无法在Postman启用的解决办法
  • 原文地址:https://www.cnblogs.com/tianpan2019/p/11505424.html
Copyright © 2020-2023  润新知