Advertisement
zoltanleo

vtv_header_paint

Aug 30th, 2023 (edited)
2,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.26 KB | None | 0 0
  1. procedure TForm1.vstAdvancedHeaderDraw(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
  2.   const Elements: THeaderPaintElements);
  3. var
  4.   r: TRect;//current rectangle
  5.   i: Integer;
  6.   cp: TPoint;//center of current rectangle
  7.   txt: string;//caption text
  8.   te: TSize;//canvas text extend
  9. begin
  10.   //Header.Options = Header.Options + [hoOwnerDraw];
  11.   if (hpeBackground in Elements) then
  12.   begin
  13.     for i := 0 to Pred(Sender.Columns.Count) do
  14.       if (PaintInfo.Column = Sender.Columns.Items[i]) then
  15.       begin
  16.         r:= PaintInfo.PaintRectangle;
  17.         if (i <> 0)
  18.           then r.Inflate(1,1,0,0)
  19.           else r.Inflate(1,1,0,0);
  20.  
  21.         PaintInfo.TargetCanvas.Brush.Color:= clBtnFace;
  22.         PaintInfo.TargetCanvas.FillRect(r);
  23.         PaintInfo.TargetCanvas.Brush.Color:= vst.Colors.TreeLineColor;
  24.         PaintInfo.TargetCanvas.FrameRect(r);
  25.  
  26.         //Sender.Columns.Items[i].Style = vsOwnerDraw
  27.         PaintInfo.TargetCanvas.Brush.Color:= clBtnFace;
  28.         PaintInfo.TargetCanvas.Font.Color:= clHotLight;
  29.  
  30.         cp:= r.CenterPoint;
  31.         txt:= Sender.Columns.Items[i].Text;
  32.         te:= PaintInfo.TargetCanvas.TextExtent(txt);
  33.         PaintInfo.TargetCanvas.TextOut(cp.X - te.cx div 2, cp.Y - te.cy div 2, txt);
  34.       end;
  35.   end;
  36. end;
Tags: vtv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement