I don't know if this is a bug or something, but if I try to disable a TTreeView
control, all the nodes become selected (grayed out)... Can anything be done to just disable the input for this control without changing the selection ? Of course, the node are not really selected, they are just visually selected, but this is annoying.
That's how the disabled control looks like when no theme is applied. You can modify it with little intervention to item drawing:
procedure TForm1.TreeView1AdvancedCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
var PaintImages, DefaultDraw: Boolean);
begin
if (not TreeView1.Enabled) and
(GetWindowTheme(TreeView1.Handle) = 0) and (Stage = cdPrePaint) then begin
TreeView1.Canvas.Brush.Color := clWindow; // or TreeView1.Color
TreeView1.Canvas.Font.Color := clGrayText;
end;
end;
Unfortunately the State
never includes 'cdsDisabled' or 'cdsGrayed' (which I didn't investigate), so the code tests if the treeview is enabled or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With