TLama

Untitled

Jul 22nd, 2014
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.92 KB | None | 0 0
  1. const
  2.   LeftTextIndent = 20;
  3.  
  4. // OnDrawText
  5. procedure TForm1.VirtualTreeDrawText(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  6.   const Text: string; const CellRect: TRect; var DefaultDraw: Boolean);
  7. var
  8.   R: TRect;
  9.   DrawFormat: Cardinal;
  10. begin
  11.   DefaultDraw := False;
  12.  
  13.   R := CellRect;
  14.   R.Left := R.Left + LeftTextIndent;
  15.   // this needs to be improved; ideal would be if the DrawFormat would be passed
  16.   // from the TCustomVirtualStringTree.DoTextDrawing method to this event
  17.   DrawFormat := DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE;
  18.   DrawTextW(TargetCanvas.Handle, PWideChar(Text), Length(Text), R, DrawFormat);
  19. end;
  20.  
  21. // OnMeasureTextWidth
  22. procedure TForm1.VirtualTreeMeasureTextWidth(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  23.   const Text: string; var Extent: Integer);
  24. begin
  25.   Extent := Extent + LeftTextIndent;
  26. end;
Advertisement
Add Comment
Please, Sign In to add comment