【问题标题】:How to use TJvBalloonWindow as the hint window for Virtual treeview?如何使用 TJvBalloonWindow 作为 Virtual treeview 的提示窗口?
【发布时间】:2010-03-30 03:42:29
【问题描述】:
我在 Office 加载项中有一个带有虚拟树视图的 'hint window leftovers' problem,现在我想自定义提示窗口来解决问题。我想使用 JVCL 包中的 TJvBallonHint,它也用于我程序的其他部分。
我继承了 TVirtualStringTree 并重写了 GetHintWindowClass 方法,如下面的代码。应用了 TJvBallonHint 窗口类,但不绘制提示文本。对我有什么建议吗?谢谢!
function TMyStringTree.GetHintWindowClass: THintWindowClass;
begin
Result :=TJvBalloonWindow;;
end;
【问题讨论】:
标签:
delphi
virtualtreeview
【解决方案1】:
自定义类应该继承自TVirtualTreeHintWindow,而TJvBalloonWindow 不是。
这不是正式要求,因为它应该只是 THintWindowClass,但请查看 TVirtualTreeHintWindow 的代码 - 它甚至不使用 Caption(这就是为什么您的提示标题为空):
procedure TVirtualTreeHintWindow.CMTextChanged(var Message: TMessage);
begin
// swallow this message to prevent the ancestor from resizing the window (we don't use the caption anyway)
end;
我建议您使用来自TJvBalloonWindow 的代码创建新的提示窗口类进行绘画。