Dian
Dian

Reputation: 1188

How do I highlight selected node of the VST?

This is my code:

procedure TfrmMain.vstListPaintText(Sender: TBaseVirtualTree;
  const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  TextType: TVSTTextType);
begin
  if vsSelected in Node.States then
    begin
      TargetCanvas.brush.color := clBlue;
      TargetCanvas.FillRect(targetcanvas.ClipRect);
    end;
end;

But this is what happens:

  1. I click the node
  2. Whole VST is painted blue except for the previous selected node
  3. The selected node is blue (and the VST is back to it's default color)

How do I avoid #2?

Upvotes: 1

Views: 278

Answers (2)

Ondrej Kelle
Ondrej Kelle

Reputation: 37221

Simple: you're FillRect-ing the whole canvas. Don't do that. Use OnAfterCellPaint or OnAfterItemPaint. In these events, you get the particular CellRect to do your custom painting.

Upvotes: 2

Tool
Tool

Reputation: 419

wrong event if you want to paint the cell - ...PaintText is for setting color and font styles.

Try other events instead (OnBeforeCellPaint) and you will get TRect for the cell automatically.

Upvotes: 4

Related Questions