首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与ExptIntf、ToolIntf和TIExpert有什么关系?

与ExptIntf、ToolIntf和TIExpert有什么关系?
EN

Stack Overflow用户
提问于 2013-12-20 15:13:54
回答 1查看 1K关注 0票数 1

在尝试将组件移动到较新版本的德尔菲时,Borland通过重命名、隐藏或删除设计时代码使用的各种类来破坏兼容性。是例行公事。

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

代码语言:javascript
复制
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Contoso3Const, StdCtrls, ExtCtrls, ContosoRpt, DBTables, ContosoDataWz, ContosoExtra,
  ExptIntf,
  ToolIntf, ContosoWizard, ActiveX;

没问题。我们将注释掉引用的内容。但是,没有找到另一个单元,即ToolIntf

代码语言:javascript
复制
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Contoso3Const, StdCtrls, ExtCtrls, ContosoRpt, DBTables, ContosoDataWz, ContosoExtra,
  //ExptIntf,
  ToolIntf, 
  ContosoWizard, ActiveX;

没问题。我们将注释掉引用的内容。这才是真正有趣的开始。

找不到类TIExpert

代码语言:javascript
复制
{$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
     ...

一位快速搜索者说这段代码在Delphi 6中是行不通的。

这就是在D4中贬值而在D6中消失的旧式OTA。您必须使用D4中引入的OTA接口样式重新编写。

海报没有提到在D4中引入的新的OTA接口风格。

考虑到我将不得不用第三方代码重写两个类:

代码语言:javascript
复制
  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;

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

注意事项:为了您的安全,第三方库的身份被混淆得很糟糕。

Note

  • 标记的delphi-5;因为这是我要移动的IDE
  • 标记的delphi-7;因为这是我要移动的IDE
  • 标记delphi-6;因为这是破坏功能代码的IDE
  • 标记为delphi,因为这是我们正在讨论的开发工具
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-20 15:30:53

TIExpert被从IOTAWizard派生的新的接口层次结构所取代。网上有很多OpenTools API教程,比如这一个,以及正式文件

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20706637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档