如何最好地在基本Delphi TVirtualTreeView节点图标上呈现叠加图标 [英] How best to render an overlay icon on top of basic Delphi TVirtualTreeView node icon
问题描述
我正在从标准TTreeView转换树视图以使用TVirtualStringTree。我最后的挑战是实现一个功能,我需要在已知节点图标的顶部绘制通过/失败状态指示器。使用TTreeView我使用:
I'm converting a tree view from the standard TTreeView to use TVirtualStringTree. My final challenge is to implement a feature where I need to draw a 'pass/fail' status indicator on top of the known node icon. With TTreeView I used:
var
R : TRect;
begin
R := Node.DisplayRect( True );
StatusIconList.Draw( TreeView1.Canvas,
R.Left - StatusIconList.Width - 14,
R.Top,
3 {MyOverlayImageIndex} );
结果是基本图标上的红叉,如下所示:
The result is the red cross over the basic icon as shown below:
使用TVirtualStringTree,我希望找到更好的方法,或者为所需的叠加图标位置获得更好的已知位置。我正在做:
With TVirtualStringTree I hoped to find either a better way, or to get better known positions for the required overlay icon position. I'm doing:
procedure DrawFailed;
var
R : TRect;
begin
R := CellRect;
StatusIconList.Draw( TargetCanvas,
R.Left - StatusIconList.Width + 49 + Sender.GetNodeLevel( Node ) * 16,
R.Top,
siiFailed );
end;
这是最好的解决方案吗?在没有可怕的节点级调用的情况下,有没有更好的方法来获取基本图标的左上角?
Is this the best solution? Is there a better way of getting the top/left corner of the basic icon without the horrible node level call?
推荐答案
你得到的种类:TVTImageKind
OnGetImageIndex
事件处理程序中的参数。检查 ikOverlay
,然后返回相应的图像索引。
You get Kind: TVTImageKind
parameter in your OnGetImageIndex
event handler. Check it for ikOverlay
and simply return the appropriate image index.
这篇关于如何最好地在基本Delphi TVirtualTreeView节点图标上呈现叠加图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!