打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
插件之接口实现

在插件中需要对接口中的方法进行具体的实现,主控程序才能调用并执行插件中的具体功能。

unit uPlug;

interface

uses
  uInterface, Forms, Windows, Classes, SysUtils;

type
  TModelService = class(TInterfacedObject, IModelInts)
  private
    function CheckFormExists(aClassName: pchar): Boolean;
  public
    procedure Cmd(aClassName: PChar);         // create visual plugin
    procedure Cmd2(aClassName: PChar);        // create non-visual plugin
  end;

implementation

{ TModelService }

function GetModelInts: IModelInts;
begin
  result := TModelService.Create();
end;

exports
  GetModelInts;

function TModelService.CheckFormExists(aClassName: pchar): Boolean;
var
  i: Integer;
begin
  result := False;
  for i := 0 to screen.FormCount - 1 do
  begin
    if UpperCase(screen.Forms[i].ClassName) = UpperCase(aClassName) then
    begin
      result := True;
      Screen.Forms[i].BringToFront;
      break;
    end;
  end;
end;

procedure TModelService.Cmd(aClassName: PChar);
var
  f: TForm;
begin
  if CheckFormExists(aClassName) then Exit;
  f := TFormClass(FindClass(aClassName)).Create(Application);
  f.Top := Application.MainForm.Height;
  f.Show;
end;

procedure TModelService.Cmd2(aClassName: PChar);
var
  f: TForm;
begin
 // if CheckFormExists(aClassName) then Exit;
  f := TFormClass(FindClass(aClassName)).Create(Application);
  f.Hide;
end;

end.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Delphi做的软件自动更新
delphi Dll 中封装多窗体
cxGrid在内置右键菜单的后面增加菜单项并实现诸多功能
Delphi 中控制 Word,xml,dll 等操作
Windows API函数使用技巧
CnPackTip#5:Delphi 中的 Idle
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服