QPlugins 015.Delphi plug it, FMX plug-in window

FMX embedded plug-in window, the effect is still very possible. When you exit, it will complain, very strange ah.

 

The main window code is as follows

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
    //Modal display window 
    // output window information 
    the ShowMessage (ServiceSource (AFormService AS IQService));
     // modal display window 
    AFormService.ShowModal ( nil , nil );
   End ;
 End ; 

// Create 
Procedure TForm_Main.FormCreate (Sender: TObject) ;
 var 
  Apath: String ;
 the begin 
  ReportMemoryLeaksOnShutdown: = True;
   // load the same catalog of DLL plug 
  Apath: = ExtractFilePath (Application.ExeName); 
  PluginsManager.Loaders.Add (TQDLLLoader. the Create (Apath,' .Dll ' ));
   // start 
  PluginsManager.Start;
 End ; 

End .

The following code DLL plug FMX

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.

 

Guess you like

Origin www.cnblogs.com/tianpan2019/p/11505424.html