Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing... 1

Status
Not open for further replies.

vacunita

Programmer
Aug 2, 2001
9,166
MX
Is there any way to print a TListView componenet. I want to print the report displayed in it in detail view. with the columns and names of columns and i want to a add a page headder with a logo and some company info. is there any whay i can do this. Someone suggested to me that I use Qreports, but since i'm not generating a database table i in dont know how i could use it. Any sugestions with the qreport or anything else....

 
Please any help would be appreciated I'm getting desperate.
 
The last couple of days I've been looking for tips with google which may be a last resort for you. Suggestion on search term:

delphi tips tlistview print(ing)

I only scanned the first page of results but it came up with a commercial component from Greatis.
 
thanx Beanso, ill look into it. I really appreciate it. thanx alot.
 
hi

I have done printing from a rich edit, with formatting. If you have an email address I can email you the code if you like. There's a bit too much to put in here.

lou
 
Hi,
hope i am not too late.

I would suggest you use the Writeln method with some formatting of your own.

of course you can change how the fonts look by saying for example
printer.Canvas.Font.Name := 'courier new';
printer.Canvas.Font.Size := 14;
printer.Canvas.Font.Style := [fsBold];
writeln(F,'Hello');
........etc

Next step..you want to print a header....
of course printing on first page wont be a problem, but printing on remaining pages will be.
so I would suggest you print a certain number of lines on each page and then say
PRINTER.NEWPAGE;

to force printing on a new page.


The last issue is printing a Logo.
here is the procedure

procedure Printlogo;
var
Info: PBitmapInfo;
InfoSize: DWORD;
Image: Pointer;
ImageSize: DWORD;
Bits: HBITMAP;
DIBWidth, DIBHeight: LongInt;
begin
Printer.BeginDoc;
try
Printer.Canvas.Lock;
try
{ Paint bitmap to the printer }
with Printer do
begin
Bits := MyBmp1.Handle;
GetDIBSizes(Bits, InfoSize, ImageSize);
Info := AllocMem(InfoSize);
try
Image := AllocMem(ImageSize);
try
GetDIB(Bits, 0, Info^, Image^);
with Info^.bmiHeader do
begin
DIBWidth := biWidth;
DIBHeight := biHeight;
end;
StretchDIBits(Canvas.Handle, 0, 0, DIBWidth*6, DIBHeight*6, 0, 0,
DIBWidth, DIBHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY);


finally
FreeMem(Image, ImageSize);
end;
finally
FreeMem(Info, InfoSize);
end;
end;
finally
Printer.Canvas.Unlock;
end;
finally
Printer.EndDoc;

end;
end;



Hope This helps...........









 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top