Skip to content

Commit 86038d4

Browse files
committed
Update VirtualTrees.pas
* For ikState use Images by default if not StateImages are assigned * Added fallback code when getting checkbox size from system failed.
1 parent 4d7e137 commit 86038d4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Source/VirtualTrees.pas

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4324,6 +4324,8 @@ function CreateSystemImageSet(pControl: TWinControl): TImageList;
43244324

43254325
//--------------- end local functions ---------------------------------------
43264326

4327+
const
4328+
cDefaultCheckboxSize = 13;// Used when no other value is available
43274329
var
43284330
I: Integer;
43294331
lSize: TSize;
@@ -4345,8 +4347,13 @@ function CreateSystemImageSet(pControl: TWinControl): TImageList;
43454347
end
43464348
else
43474349
Res := StyleServices.GetElementSize(BM.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxUncheckedNormal), TElementSize.esActual, lSize);
4348-
if not Res then
4350+
if not Res then begin
43494351
lSize := TSize.Create(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK));
4352+
if lSize.cx = 0 then begin
4353+
lSize.cx := ScaledPixels(cDefaultCheckboxSize);
4354+
lSize.cy := lSize.cx;
4355+
end;// if
4356+
end;//if
43504357

43514358
Result := TImageList.CreateSize(lSize.cx, lSize.cy);
43524359
with Result do
@@ -20069,7 +20076,7 @@ function TBaseVirtualTree.DoGetImageIndex(Node: PVirtualNode; Kind: TVTImageKind
2006920076
const
2007020077
cTVTImageKind2String: Array [TVTImageKind] of string = ('ikNormal', 'ikSelected', 'ikState', 'ikOverlay');
2007120078
begin
20072-
if Kind = ikState then
20079+
if (Kind = ikState) and Assigned(StateImages) then
2007320080
Result := Self.StateImages
2007420081
else
2007520082
Result := Self.Images;

0 commit comments

Comments
 (0)