show bold nodes in TTreeview component
?
uses
CommCtrl;
procedure SetNodeBoldState(Node: TTreeNode; Value: Boolean);
var
TVItem: TTVItem;
begin
if not Assigned(Node) then Exit;
with TVItem do
begin
mask := TVIF_STATE or TVIF_HANDLE;
hItem := Node.ItemId;
stateMask := TVIS_BOLD;
if Value then state := TVIS_BOLD
else
state := 0;
TreeView_SetItem(Node.Handle, TVItem);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetNodeBoldState(TreeView1.Items[0], True);
end;
procedure SetNodeState(node: TTreeNode; Flags: Integer);
var tvi: TTVItem;
begin
FillChar(tvi, SizeOf(tvi), 0);
tvi.hItem := node.ItemID;
tvi.Mask := TVIF_STATE;
tvi.StateMask := TVIS_BOLD or TVIS_CUT;
tvi.State := Flags;
TreeView_SetItem(node.Handle, tvi);
end;
And now we can set a wished flags:
SetNodeState(node, TVIS_BOLD) - to set the node as Bold
SetNodeState(node, TVIS_CUT) - to set the node as Cutted
SetNodeState(node, TVIS_BOLD or TVIS_CUT) - to set the node as Bold and Cutted
SetNodeState(node, 0) - to set a node as normal