Author: Tomas Rutkauskas
How to print a TTreeView
Answer:
1 var2 bmp: TBitmap;
3 begin4 bmp := TBitmap.Create;
5 try6 bmp.width := treeview.width;
7 bmp.height := treeview.height;
8 bmp.canvas.lock;
9 try10 treeview.perform(WM_PRINT, bmp.canvas.handle, PRF_CHILDREN or11 PRF_CLIENT or PRF_NONCLIENT);
12 finally13 bmp.canvas.unlock;
14 end;
15 { ... print the bitmap as device-independent bitmap }16 finally17 bmp.free
18 end;
19 end;
Drawing directly to the printer canvas is probably possible but you have to mess with mapping modes, scale the printer canvas, move its origin and so on, the above may be easier to code, especially if you already have a PrintBitmap routine flying around somewhere.