How do I fill in the area above the scroll bar in a TVirtualStringTree?
Asked Answered
G

1

10

I have a need to fill in (with black) the little white square that I've highlighted in the picture below.

I have tried adding extra columns. I have tried expanding the PaintInfo.PaintRectangle. I have tried every setting on the Amount column that I can think of. I am out of ideas.

Anyone have any ideas on how to do that?

Here is the code that does the custom header drawing. (Forgive the with statement, not my original code....)

procedure TWinPOSReceiptPluginForm.ReceiptDisplayTreeAdvancedHeaderDraw(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
  const Elements: THeaderPaintElements);
var
    TempText: string;
begin
    with PaintInfo do
    begin
      // First check the column member. If it is NoColumn then it's about the header background.

        if (hpeBackground in Elements) and (Column <> nil) then begin
          TempText := Column.Text;
          TargetCanvas.Brush.Color := $444444;
          TargetCanvas.FillRect(PaintRectangle);
          TargetCanvas.Font.Color := clWhite;
          TargetCanvas.Font.Style := [];
          TargetCanvas.TextOut (PaintRectangle.Left + 3, PaintRectangle.Top + 3, TempText);
          end;
    end;
end;

enter image description here

Guardsman answered 6/10, 2015 at 15:43 Comment(4)
This doesn't look like the plain vanilla themeSuperpatriot
How did you make the header have a different color? VCL themes? Custom paint? Something else?Legislature
Added code showing how custom header is getting drawn.Guardsman
As a side note, the area can be covered if one puts the cursor on the left edge of the box and drags the column over, so there is some way to paint in that area.Guardsman
L
12

Your if condition is wrong. It will never be true when hpeBackground is in Elements for that area because in that case Column is nil.

Since the Column nil check is only needed for getting the Column.Text you need to change that code:

if hpeBackground in Elements then
begin
  if Column <> nil then
    TempText := Column.Text;
  TargetCanvas.Brush.Color := $444444;
Legislature answered 6/10, 2015 at 18:20 Comment(1)
You are, as always, the man. Should have occurred to me. Thanks very much.Guardsman

© 2022 - 2024 — McMap. All rights reserved.