Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- LeftTextIndent = 20;
- // OnDrawText
- procedure TForm1.VirtualTreeDrawText(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
- const Text: string; const CellRect: TRect; var DefaultDraw: Boolean);
- var
- R: TRect;
- DrawFormat: Cardinal;
- begin
- DefaultDraw := False;
- R := CellRect;
- R.Left := R.Left + LeftTextIndent;
- // this needs to be improved; ideal would be if the DrawFormat would be passed
- // from the TCustomVirtualStringTree.DoTextDrawing method to this event
- DrawFormat := DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE;
- DrawTextW(TargetCanvas.Handle, PWideChar(Text), Length(Text), R, DrawFormat);
- end;
- // OnMeasureTextWidth
- procedure TForm1.VirtualTreeMeasureTextWidth(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
- const Text: string; var Extent: Integer);
- begin
- Extent := Extent + LeftTextIndent;
- end;
Advertisement
Add Comment
Please, Sign In to add comment