【发布时间】:2013-12-20 15:13:54
【问题描述】:
在尝试将组件移动到较新版本的 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:
那是在 D4 中贬值并在 D6 中消失的旧式 OTA。你会 必须使用D4中引入的OTA界面样式重新编写。
海报并没有提到D4中引入的新OTA界面风格是什么。
鉴于我将不得不在 3rd 方代码中重写两个类:
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,因为这就是我们正在讨论的开发工具
【问题讨论】:
-
这是非常旧的 API,在 D7 的时候肯定被认为是过时的。较新的旧代码
uses ToolsAPI. -
“日常缺乏向后兼容性”?这发生过一次(当 Unicode 与 D2009 添加时)。您提到的更改不是“常规”,并且提前宣布了两个版本(D4-> D6)并记录在案。 Borland 多年来一直没有参与 Delphi。如果你要抱怨,至少抱怨事实问题。 :-) (不过,当您的抱怨是关于从〜Y2K 产品升级到〜2002 年的产品时,这并没有真正的意义,这仍然有十多年的历史。我相信人们从 16 位 Win 3.1 迁移到今天的 Win 95 也在处理重大问题。):-D
-
@Ian 我不敢相信你终于要离开 Delphi 5 并进入现代时代。哦,等等..... ;-)
-
OTA有很多变化。但后来 IDE 也发生了变化。为什么 Emba 应该在 OTA 中保持对旧 IDE 的兼容性。在我看来,对于 OTA 来说,当然欢迎他们做出改变。事实上,我希望他们比他们更能破坏兼容性。这样他们就可以摆脱过去。
-
@IanBoyd——承认在 StackOverflow 上公开使用盗版是一个大胆的举动。我建议没有人帮助你。
标签: delphi delphi-7 delphi-5 delphi-6