delphi - ExptIntf 和 ToolIntf 以及 TIExpert 有何用途?

标签 delphi delphi-7 delphi-5 delphi-6

按照惯例,尝试将组件移动到较新版本的 Delphi 时,Borland breaks compatibility by renaming, hiding, or removing various classes used by design time code .

今天的案例涉及我们几年前购买的一个代码库,我们有它的源代码。当找不到单元 ExptIntf 时,尝试在 Delphi 7 IDE 中安装“设计时”包会失败:

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Contoso3Const, StdCtrls, ExtCtrls, ContosoRpt, DBTables, ContosoDataWz, ContosoExtra,
  ExptIntf,
  ToolIntf, ContosoWizard, ActiveX;

没问题。我们将注释掉引用。但是另一个单元 ToolIntf 没有找到:

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Contoso3Const, StdCtrls, ExtCtrls, ContosoRpt, DBTables, ContosoDataWz, ContosoExtra,
  //ExptIntf,
  ToolIntf, 
  ContosoWizard, ActiveX;

没问题。我们将注释掉引用。这才是真正的乐趣开始的时候。

找不到类TIExpert:

{$INCLUDE compilers.inc}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Contoso3Const, StdCtrls, ExtCtrls, ContosoRpt, DBTables, ContosoDataWz, ContosoExtra,
  {$IFDEF DELPHI_6_UP}
  //They've been removed in D6
  //ExptIntf, ToolIntf,
  {$ELSE}
  ExptIntf, ToolIntf,
  {$ENDIF}
  ContosoWizard, ActiveX;

type
  TContosoIDEWizard = class(TIExpert)
  public
     ...

快速谷歌搜索显示 the code will never work in Delphi 6 :

That is the old style OTA that was depreciated in D4 and gone in D6. You will have to re write using the OTA interface style introduced in D4.

海报没有提及D4中引入的新OTA界面风格是什么。

鉴于我将不得不在第三方代码中重写两个类:

  TContosoIDEWizard = class(TIExpert)
  public
    SourceBuffer: PChar;
    function GetName: string; override;
    function GetComment: string; override;
    function GetGlyph: HICON; override;
    function GetStyle: TExpertStyle; override;
    function GetState: TExpertState; override;
    function GetIDString: string; override;
    function GetAuthor: string; override;
    function GetPage: string; override;
    procedure Execute; override;
    function CreateForm(Report : TCustomContosoRep; const FormIdent : string; VarList : TStrings) : TMemoryStream;
    function CreateSource(const UnitIdent, FormIdent: string; VarList : TStrings): TMemoryStream;
  end;

  TNewContosoReport = class(TIExpert)
    function GetName: string; override;
    function GetComment: string; override;
    function GetGlyph: HICON; override;
    function GetStyle: TExpertStyle; override;
    function GetState: TExpertState; override;
    function GetIDString: string; override;
    function GetAuthor: string; override;
    function GetPage: string; override;
    function GetMenuText: string; override;
    procedure Execute; override;
  end;

将它们重写成什么?我认为它就像使用不同的基类名称一样简单,其中包含所有相同的方法,并且不需要实际的代码重写(我没有编写的代码)。

注意:为了您的安全,第 3 方库的身份已被严重混淆

注意:

  • 标记为delphi-5;因为那是我要迁移的 IDE
  • 已标记delphi-7;因为这就是我要迁移到的 IDE
  • 标记为delphi-6;因为这是破坏正常运行代码的 IDE
  • 标记为 delphi,因为这就是我们正在讨论的开发工具

最佳答案

TIExpert 已替换为源自 IOTAWizard 的新接口(interface)层次结构。网上有很多OpenTools API教程,比如this one ,以及official documentation .

关于delphi - ExptIntf 和 ToolIntf 以及 TIExpert 有何用途?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20706637/

相关文章:

delphi - 组件可以用它自己的处理程序替换它的所有者表单的事件(OnClose)吗?

delphi - 禁用/停用具有已发布属性的自定义组件

delphi - 如何吃掉从流中流出的字节?

delphi - 如何使用 Delphi 计算特定日期和位置的潮汐

delphi - Apache 2.2模块

Delphi MDI 应用程序下一个窗口菜单项

c# - 在 Delphi 中,Math.Round() 与 MidpointRounding.AwayFromZero 的等效项是什么?

delphi - 将应用程序从 Delphi 迁移到 Silverlight C#

delphi - 在图表上设置左轴以将十进制值增加到0.13?

ios - Rad Studio XE8 : "Run" button not enabled for iOS64 target