在尝试将组件移动到较新版本的德尔菲时,Borland通过重命名、隐藏或删除设计时代码使用的各种类来破坏兼容性。是例行公事。
今天的例子涉及我们几年前购买的代码库,我们有源代码。当找不到单元ExptIntf时,尝试在Delphi7IDE中安装“设计时”包失败:
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
...一位快速搜索者说这段代码在Delphi 6中是行不通的。
这就是在D4中贬值而在D6中消失的旧式OTA。您必须使用D4中引入的OTA接口样式重新编写。
海报没有提到在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;把它们改写成什么?我假设它就像使用不同的基类名称一样简单,它包含所有相同的方法,并且不需要实际的代码重写(我没有编写的代码)。
注意事项:为了您的安全,第三方库的身份被混淆得很糟糕。
Note
delphi-5;因为这是我要移动的IDEdelphi-7;因为这是我要移动的IDEdelphi-6;因为这是破坏功能代码的IDEdelphi,因为这是我们正在讨论的开发工具发布于 2013-12-20 15:30:53
TIExpert被从IOTAWizard派生的新的接口层次结构所取代。网上有很多OpenTools API教程,比如这一个,以及正式文件。
https://stackoverflow.com/questions/20706637
复制相似问题