- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将 vtTest
组件中的 ImageList1
中的图像显示为叠加层。
我在互联网上和这里找到了很多资源 - 例如 this - 但我无法让它们都正常工作。
我确信我错过了一些非常微不足道的东西,但我不知道它可能是什么。
<小时/>我得到的: 我想要的是:
<小时/>这是包含显示我的问题的基本示例的表单。
Unit1.pas
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VirtualTrees, Vcl.ImgList;
type
PMyVtTestData = ^TMyVtTestData;
TMyVtTestData = record
isLocked: Boolean;
end;
TForm1 = class(TForm)
vtTest: TVirtualStringTree;
ImageList1: TImageList;
procedure FormCreate(Sender: TObject);
procedure vtTestGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode;
Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean;
var ImageIndex: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i, j, m: Integer;
Node, Node1, Node2: PVirtualNode;
procedure SetCustomNodeDataValue(const Node: PVirtualNode; const Value: Boolean = False);
var
Data: PMyVtTestData;
begin
Data := vtTest.GetNodeData(Node);
Data^.isLocked := Value;
end;
begin
vtTest.NodeDataSize := SizeOf(TMyVtTestData);
//initialize some node
//every TMyVtTestData.isLocked = False, except the 3rd TMyVtTestData.isLocked which is True
Randomize;
for i := 0 to Random(3)+3 do begin
Node := vtTest.AddChild(nil);
SetCustomNodeDataValue(Node, i = 2);
for j := 0 to Random(3)+2 do begin
Node1 := vtTest.AddChild(Node);
SetCustomNodeDataValue(Node1);
for m := 0 to Random(5) do begin
Node2 := vtTest.AddChild(Node1);
SetCustomNodeDataValue(Node2);
end;
end;
end;
end;
procedure TForm1.vtTestGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
var
Data: PMyVtTestData;
begin
if Node = nil then
Exit;
case Column of
0: begin
if Kind in [ikNormal, ikSelected] then
ImageIndex := 0
else if Kind = ikOverlay then begin
Data := Sender.GetNodeData(Node);
if Data^.isLocked then
ImageIndex := 1;
end;
end;
end;
end;
end.
Unit1.dfm
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 300
ClientWidth = 313
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
DesignSize = (
313
300)
PixelsPerInch = 96
TextHeight = 13
object vtTest: TVirtualStringTree
Left = 8
Top = 8
Width = 298
Height = 284
Anchors = [akLeft, akTop, akRight, akBottom]
Header.AutoSizeIndex = -1
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.Images = ImageList1
Header.Options = [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
Images = ImageList1
TabOrder = 0
OnGetImageIndex = vtTestGetImageIndex
Columns = <
item
Position = 0
Width = 200
WideText = 'column'
end>
end
object ImageList1: TImageList
Left = 256
Top = 240
Bitmap = {
494C010102000500040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001002000000000000010
0000000000000000000000000000000000000000000000000000000000000000
0000868686003535350000000000000000000000000000000000939393005757
5700000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000D9D9
D9000505050000000000B1B1B1000000000000000000FCFCFC00222222000000
0000A2A2A2000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000CCCC
CC00353535007D7D7D002525250066666600939393001E1E1E00646464003434
340085858500000000000000000000000000000000000000000000000000140C
EB00B1AEF900FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B1AE
F900140CEB000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000006E6E6E0000000000000000002E2E2E00000000000000
0000000000000000000000000000000000000000000000000000140CEB000000
00000300EA00B9B6F900FFFFFF00FFFFFF00FFFFFF00FFFFFF00B9B6F9000300
EA0000000000140CEB0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000007171
7100000000002F2F2F0015151500D0D0D000F0F0F00031313100252525002121
21005F5F5F000000000000000000000000000000000000000000B1AEF9000300
EA002018EC00160DEC00B9B6F900FFFFFF00FFFFFF00B9B6F900160DEC002018
EC000300EA00B1AEF90000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000BFBF
BF00000000002222220000000000000000000000000000000000666666000000
0000979797000000000000000000000000000000000000000000FFFFFF00B9B6
F900160DEC002018EC000300EA00B1AEF900B1AEF9000300EA002018EC00160D
EC00B9B6F900FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000096969600B9B9B900000000007676760048484800D8D8D800EEEEEE006565
6500F8F8F8000000000000000000000000000000000000000000FFFFFF00FFFF
FF00B9B6F9000300EA0000000000140CEB00140CEB00000000000300EA00B9B6
F900FFFFFF00FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000E9E9E900313131000000000010101000000000009F9F9F000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00B1AEF900140CEB000000000000000000140CEB00B1AEF900FFFF
FF00FFFFFF00FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000001919190000000000353535007272720000000000000000009999
9900000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00B1AEF900140CEB000000000000000000140CEB00B1AEF900FFFF
FF00FFFFFF00FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00009A9A9A003B3B3B00000000004F4F4F0000000000B3B3B300C3C3C3004040
4000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00B9B6F9000300EA0000000000140CEB00140CEB00000000000300EA00B9B6
F900FFFFFF00FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000D0D0D0062626200000000006F6F6F0000000000E5E5E500000000000000
0000ADADAD000000000000000000000000000000000000000000FFFFFF00B9B6
F900160DEC002018EC000300EA00B1AEF900B1AEF9000300EA002018EC00160D
EC00B9B6F900FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000E2E2
E2000202020001010100555555000A0A0A000000000033333300444444000000
0000848484000000000000000000000000000000000000000000B1AEF9000300
EA002018EC00160DEC00B9B6F900FFFFFF00FFFFFF00B9B6F900160DEC002018
EC000300EA00B1AEF90000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DEDE
DE00040404000000000000000000000000000000000000000000000000000000
00007E7E7E000000000000000000000000000000000000000000140CEB000000
00000300EA00B9B6F900FFFFFF00FFFFFF00FFFFFF00FFFFFF00B9B6F9000300
EA0000000000140CEB0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00003C3C3C000000000000000000000000000000000000000000000000000000
0000BDBDBD00000000000000000000000000000000000000000000000000140C
EB00B1AEF900FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B1AE
F900140CEB000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000E1E1E1000E0E0E0000000000000000000000000000000000000000007676
7600000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000F5F5F5008787870042424200363636005C5C5C00C3C3C3000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000100000000100010000000000800000000000000000000000
000000000000000000000000FFFFFF00F3CFFFFF00000000E187FFFF00000000
E007E00700000000FC3FD00B00000000E007C00300000000E3C7C00300000000
F207C24300000000F81FC18300000000F80FC18300000000F20FC24300000000
F227C00300000000E007C00300000000E007D00B00000000F007E00700000000
F00FFFFF00000000F81FFFFF0000000000000000000000000000000000000000
000000000000}
end
end
<小时/>
提示:
ImageIndex := 1;
行在 vtTestGetImageIndex
函数中执行 - 设置断点后调试器将停止0
和 1
处的图像确实存在于 TImageList
最佳答案
您的项目缺少两件事。
OnGetImageIndexEx
,而不是普通的OnGetImageIndex
。 当您检查 VTV 的源时,原因就会很清楚。
procedure TBaseVirtualTree.PaintImage(var PaintInfo: TVTPaintInfo; ImageInfoIndex: TVTImageInfoIndex; DoOverlay: Boolean);
....
// Now, draw the overlay. This circumnavigates limitations in the overlay mask index (it has to be 4 bits in size,
// anything larger will be truncated by the ILD_OVERLAYMASK).
// However this will only be done if the overlay image index is > 15, to avoid breaking code that relies
// on overlay image indices (e.g. when using system image lists).
if PaintInfo.ImageInfo[iiOverlay].Index >= 15 then //<<------!
// Note: XPos and YPos are those of the normal images.
DrawImage(ImageInfo[iiOverlay].Images, ImageInfo[iiOverlay].Index, Canvas, XPos, YPos,
Style[ImageInfo[iiOverlay].Images.ImageType] or ExtraStyle, DrawEnabled);
!! Overlays with index < 15 do not get considered !!
如果您不使用OnGetImageIndexEx
,则从中选择叠加层的图像列表将为nil,请参阅:
function TBaseVirtualTree.DoGetImageIndex(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var Index: Integer): TCustomImageList;
// Queries the application/descendant about certain image properties for a node.
// Returns a custom image list if given by the callee, otherwise nil.
begin
Result := nil;
// First try the enhanced event to allow for custom image lists.
if Assigned(FOnGetImageEx) then
FOnGetImageEx(Self, Node, Kind, Column, Ghosted, Index, Result)
else !! only the ....EX works for me !!
if Assigned(FOnGetImage) then
FOnGetImage(Self, Node, Kind, Column, Ghosted, Index);
end;
如果我使用以下代码,您的叠加层将起作用:
procedure TForm1.vtTestGetImageIndexEx(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer; var ImageList: TCustomImageList);
var
Data: PMyVtTestData;
begin
if Node = nil then Exit;
case Column of
0: begin
if Kind in [ikNormal, ikSelected] then ImageIndex:= 0
else if Kind = ikOverlay then begin
Data:= Sender.GetNodeData(Node);
if Data^.isLocked then
ImageIndex:= 1+16;
end;
end;
end;
ImageList:= Self.ImageList1; //Or use a separate imagelist for overlays.
end;
即使叠加层的图像索引 < 15 也不会被考虑,VTV 不会从索引中减去任何数字,因此您必须在图像列表中放置至少 15 个图像。
现在可以了:
关于delphi - 使用 TVirtualStringTree.OnGetImageIndex 覆盖图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36909591/
我知道 C++ 中的 overriding 是什么。但是,是否存在覆盖?如果有,是什么意思? 谢谢。 最佳答案 在 C++ 术语中,您有 覆盖(与类层次结构中的虚拟方法相关)和 重载(与具有相同名称但
我想捕获位于另一个元素下的元素的鼠标事件。 这是我所拥有的示例:http://jsfiddle.net/KVLkp/13/ 现在我想要的是当鼠标悬停在红色方 block 上时蓝色方 block 有黄色
以下报道 here我尝试创建一个带有重叠散点图的箱线图。 但是当我运行时: In [27]: table1.t_in[table1.duration==6] Out[27]: counter 7
有一个 JS Fiddle here , 你能在不克隆到新对象的情况下替换 e.target 吗? 下面重复了那个 fiddle 的听众; one.addEventListener('click',
首先要解决重复的可能性: 我不是询问 Override 是什么、它的含义或 @Override 在 java 文档注释之外。那是我不是问 /**Some JavaDoc Comment*/ @over
我想要高于定义的数组。它存储点及其坐标。 public static List simpleGraph(List nodes) { int numEdges = nodes.size() *
我在 http://olisan.dk/blog/ 有一个博客- 如您所见,有一个 28 像素的高间隙(边距顶部)...在 style.css 中: margin-top: 0; 也被设置为 marg
Vulkan 句柄是指向 struct 的不透明指针,或者只是无符号的 64 位整数,具体取决于 VK_USE_64_BIT_PTR_DEFINES 的值: #if (VK_USE_64_BI
我正在尝试提供一个行为类似于 DataGridTextColumn 的 DataGrid 列,但在编辑模式下有一个附加按钮。我查看了 DataGridTemplateColumn,但似乎更容易将 Da
使用 Django 1.10 我想在用户名中允许\字符,因为我在使用“django.contrib.auth.middleware.RemoteUserMiddleware”的 Windows 环境中
我正在尝试使用 ffmpeg 将 Logo 放入 rtmp 流中。我的 ffmpeg 版本是 ffmpeg version 4.3.1目前在我的复杂过滤器中,我有: ffmpeg -re -i 'v
是否有用于Firebase 3存储的方法/规则来禁用文件更新或覆盖? 我为数据库找到了data.exists(),但没有为存储找到解决方案。 最佳答案 TL; DR:在Storage Security
我有两个 Docker Compose 文件,docker-compose.yml看起来像这样 version: '2' services: mongo: image: mongo:3.2
我需要覆盖 JPA 中的集合表吗?也许有人有想法 public class nationality{ @Embedded @AttributeOverrides({
嗨,我正在使用 WIX 和下面的代码将文件安装到目录中。 我的应用程序的工作方式是用户可以在该目录中复制他们自己的文件,覆盖他们喜欢的内容
我正在尝试为 Lua 中的字符串实现我自己的长度方法。 我已成功覆盖字符串的 len() 方法,但我不知道如何为 # 运算符执行此操作。 orig_len = string.len function
在Scala 2.10.4中,给出以下类: scala> class Foo { | val x = true | val f = if (x) 100 else 200
我想做上面的事情。 我过去覆盖了许多文件...... block ,模型,助手......但这个让我望而却步。 谁能看到我在这里做错了什么: (我编辑了这段代码......现在包括一些建议......
根据javadoc An instance method in a subclass with the same signature (name, plus the number and the ty
我有一段代码,只要有可用的新数据作为 InputStream 就会生成新数据。每次都覆盖同一个文件。有时文件在写入之前变为 0 kb。 Web 服务会定期读取这些文件。我需要避免文件为 0 字节的情况
我是一名优秀的程序员,十分优秀!