TVirtualStringTree - how to draw header columns without using OwnerDraw?

I would like to use header columns TVirtualStringTree

, but I have a problem. I need the columns of the tree to use the "default" and add my own graphics to it.

If I use hoOwnerDraw

with Header.Options

and use OnHeaderDraw

, I need to draw the columns completely (this is not useful).

There is OnAdvancedHeaderDraw

one for which I hope ( see example ):

Used when owner is allowed for the header and the owner is draw mode for the column. But only if OnHeaderDrawQueryElements will return at least one element that will be drawn by the application.

If I use OnAdvancedHeaderDraw

(I should also use OnHeaderDrawQueryElements

) I get what I want, but I need to replace at least one element in OnHeaderDrawQueryElements

(i.e. hpeBackground

/ hpeDropMark

/ hpeHeaderGlyph

/ hpeSortGlyph

/ hpeText

) and draw it directly on the event OnAdvancedHeaderDraw

.

When, for example, I return an item hpeSortGlyph

, the return ShowSortGlyph := True

in var PaintInfo: THeaderPaintInfo

OnAdvancedHeaderDraw

is irrelevant, and the sort glyph is not colored, which means I have to draw it myself. Since no DefaultDrawSortGlyph

, I need to rethink, so to speak, in the same way as copying large chunks of code from the VT source to draw the sort glyph: /

I use / need all items in columns, I just want to add my own graphics on top of the default column graphs (down arrow) without replacing one of them. How can I avoid this behavior? Is it possible to draw on top of an exist column without fixing the source?

Hope my question is clear.

+3


source to share


1 answer


Since VT 7.0 you can query and draw the hpeOverlay element .


For older versions:

There is currently no easy way to draw a fully rendered header column (VT 6.7.0). But a simple modification of the source code could be, for example, the THeaderPaintElements extension set to, for example, hpeOverlay , and the line:

ActualElements := RequestedElements * [hpeHeaderGlyph, hpeSortGlyph, hpeDropMark,
  hpeText];

      



change to:

ActualElements := RequestedElements * [hpeHeaderGlyph, hpeSortGlyph, hpeDropMark,
  hpeText, hpeOverlay];

      

Then you can request only element hpeOverlay in the event OnHeaderDrawQueryElements , all elements will be painted with the default and the event OnAdvancedHeaderDraw will only run for this new element.

Main contributor Joachim Marder has filed an improvement issue to add this type of extension that has been committed to the repository, so the current VT version supports the proposed improvement.

+3


source







All Articles