Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.vstAdvancedHeaderDraw(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
- const Elements: THeaderPaintElements);
- var
- r: TRect;//current rectangle
- i: Integer;
- cp: TPoint;//center of current rectangle
- txt: string;//caption text
- te: TSize;//canvas text extend
- begin
- //Header.Options = Header.Options + [hoOwnerDraw];
- if (hpeBackground in Elements) then
- begin
- for i := 0 to Pred(Sender.Columns.Count) do
- if (PaintInfo.Column = Sender.Columns.Items[i]) then
- begin
- r:= PaintInfo.PaintRectangle;
- if (i <> 0)
- then r.Inflate(1,1,0,0)
- else r.Inflate(1,1,0,0);
- PaintInfo.TargetCanvas.Brush.Color:= clBtnFace;
- PaintInfo.TargetCanvas.FillRect(r);
- PaintInfo.TargetCanvas.Brush.Color:= vst.Colors.TreeLineColor;
- PaintInfo.TargetCanvas.FrameRect(r);
- //Sender.Columns.Items[i].Style = vsOwnerDraw
- PaintInfo.TargetCanvas.Brush.Color:= clBtnFace;
- PaintInfo.TargetCanvas.Font.Color:= clHotLight;
- cp:= r.CenterPoint;
- txt:= Sender.Columns.Items[i].Text;
- te:= PaintInfo.TargetCanvas.TextExtent(txt);
- PaintInfo.TargetCanvas.TextOut(cp.X - te.cx div 2, cp.Y - te.cy div 2, txt);
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement