Delphi 7 和 Delphi 2010 之间的 TVirtualStringTree 兼容性 - “参数列表不同”
我制作了一个包含在 Delphi 7 和 Delphi 2010 中工作的 TVirtualStringTree 的表单。我注意到,当我在两个平台之间移动时,我在树事件上收到消息“...参数列表不同..”,并且字符串类型在 TWideString (D7) 和 string (D2010) 之间变化。我发现可以抑制此错误的唯一技巧是使用编译器指令,如下所示:
{$IFDEF TargetDelphi7}
procedure VirtualStringTree1GetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
{$ELSE}
procedure VirtualStringTree1GetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
{$ENDIF}
并在实现事件的地方重复此操作。我是否缺少一个简单的解决方案? 谢谢。
I've made a form containing a TVirtualStringTree that works in Delphi 7 and Delphi 2010. I notice that as I move between the two platforms I get the message '...parameter list differ..' on the tree events and that the string type is changing bewteen TWideString (D7) and string (D2010). The only trick I've found to work to suppress this error is to use compiler directives as follows:
{$IFDEF TargetDelphi7}
procedure VirtualStringTree1GetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
{$ELSE}
procedure VirtualStringTree1GetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
{$ENDIF}
and to repeat this where the events are implemented. Am I missing a simple solution?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最简单的解决方案是为 D7 和 D2010 维护单独的源文件夹和组件文件夹。最终会节省时间并减少头痛。
The simplest solution would be to maintain separate source and component folders for D7 and D2010. It will save time and headaches in the end.
您还可以尝试在 VirtualTrees 单元中声明一个新类型:
并更改所有事件签名以使用此新类型,这将使您能够保持 .dfm 文件兼容且不受这些条件的影响。
You could also try declaring a new type in
VirtualTrees
unit:and change all event signatures to use this new type which should enable you to keep your .dfm files compatible and free of these conditionals.
我可以建议 3 个解决方案。对于我自己的代码,我使用解决方案 (1),因为对于我的应用程序,需要在 Delphi 7 和 Delphi 2010 之间共享的代码很少。
I can suggest 3 solutions. For my own code I used solution (1) because for my applications very little code needs to be shared between Delphi 7 and Delphi 2010.
我认为这个老问题已经解决了,因为
VirtualTrees.pas
已转换为使用UnicodeString
,并为旧编译器进行了定义:我不知道什么时候
UnicodeString引入了
,但我知道string
现在是UnicodeString
的别名(可怜的WideString
,没人爱他 - i知道他的感受)。i think this old question has been resolved, as
VirtualTrees.pas
was converted to useUnicodeString
, with a define for older compilers:i don't know when
UnicodeString
was introduced, but i knowstring
is nowadays an alias forUnicodeString
(poorWideString
, nobody loves him - i know how he feels).