Peter Kiers
asked on
How to print a listview
Hi,
Can someone tell me how to print a listview.
Or know an example.
PK
Can someone tell me how to print a listview.
Or know an example.
PK
Continuetion of this link;
https://www.experts-exchange.com/questions/26312768/Put-the-contents-of-a-listview-in-the-body-of-an-email.html
Just add 1button again and a Timage, that makes 3buttons now from previous post.
https://www.experts-exchange.com/questions/26312768/Put-the-contents-of-a-listview-in-the-body-of-an-email.html
Just add 1button again and a Timage, that makes 3buttons now from previous post.
procedure TForm1.Button3Click(Sender: TObject);
var
bmp: TBitmap;
begin
{-R}
bmp:= Tbitmap.Create;
try
bmp.width := listview1.width;
bmp.height := listview1.height;
with bmp.canvas do
begin
Lock;
try
listview1.perform( WM_PRINT, handle, PRF_CHILDREN or PRF_CLIENT or PRF_NONCLIENT or PRF_ERASEBKGND );
finally
Unlock
end;
image1.picture.bitmap := bmp;
end;
finally
bmp.free
end;
{+R}
end;
IF
this does not help, try this link;
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21064698.html
systan, that is a nice code, only problem with that kind of approach is that it will print like it is displayed on screen. Much like a bitmap screen capture and printing of the image. So if there are lots of lines, you will get printed only the ones visible
Realizing ones own printing layout using Canvas methods can be a bitch, fastidious work, but that is the only way to get perfect results, customizable at will (because you can decide every aspect of the rendering), and only real alternative is to use Reporting tools - Rave reports for example
Realizing ones own printing layout using Canvas methods can be a bitch, fastidious work, but that is the only way to get perfect results, customizable at will (because you can decide every aspect of the rendering), and only real alternative is to use Reporting tools - Rave reports for example
ASKER
I go for the solution from Epasquier.
But I can not test it yet, because I have no printer installed.
I have asked a long time ago how to install a virtual printer.
So i can test my code. But I can not find the question anymore.
Does someone know the answer to that?
P.
But I can not test it yet, because I have no printer installed.
I have asked a long time ago how to install a virtual printer.
So i can test my code. But I can not find the question anymore.
Does someone know the answer to that?
P.
ASKER
ASKER
I have test the code from espasquier, but it prints only the first column.
P.
P.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks it works.
Peter Kiers
Peter Kiers
basically, you use printers unit, where is declared the Printer function giving you a TPrinter object
With it, you access the currently selected printer, you can change it from all the printers available, you can start the printing of a document, add pages etc... and you draw on each pages whatever you want like in all bitmap canvas
In the case of printing a TListView, you will have quite a bit work to do to print nicely all the columns. That depends on what you need really
Open in new window