Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips

#5: Can I display a node in standard TTreeView component with bold style without custom drawing?

Time-to-time I receive the question how I realized a selection by the bold font for some nodes in the SMReport Explorer form.

Today I have decided to describe this very simple way (but very useful). It does not require an override of any custom drawing methods/events, creating
a new component etc. It's a real standard way.
The standard Windows Treeview control have a few state flags (TVIS_BOLD and TVIS_CUT in our example), due to which it's possible to reach wished.

At first, let's write the procedure SetNodeState:

procedure SetNodeState(node: TTreeNode; Flags: Integer);
var tvi: TTVItem;
  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);

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
SetNodeState(node, 0) - to set a node as normal

PS: tomorrow I'll release a new SMReport Designer and SMReport Autogenerated.
In new distribution kit I shall include the new demo
application with sources, in which you can view a SetNodeState procedure using too.

Published: August 3, 1999

See also
ABA Document Convert
Word Web-stream
dBase Viewer
Protected Storage Viewer
Mail parser (ActiveX)
Fast Document Viewer
Database Information Manager
SMExport suite
ABA Picture Convert

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.

SMExport advertising