Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Print a TListView Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
10
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Peter Below

I have a TListView component on my form. When I call 
listview1.paintto(printer.handle,30,30), where listview1 is of type TListView, the 
content of the grid is printed like expected, but the column headings are not 
printed. Is this a (windows?) bug or is it just me using the PaintTo the wrong way?

Answer:

It is no bug, just a problem caused by the way PaintTo works. Basically it sends a 
WM_PAINT message to a control with a canvas handle in wparam. This tells the 
control to paint its client area to the canvas. The problem in your case is that 
the listview header is not part of the listviews client area, it is an embedded 
header control. So you need to send that one a paint message as well. Unfortunately 
it has no VCL wrapper control, so PaintTo cannot be used. There is a little-known 
Windows message that can be used as alternative to WM_PAINT. The problem is that 
not all controls seem to implement it. But TListview does:
1   
2   procedure TForm1.Button1Click(Sender: TObject);
3   var
4     bmp: TBitmap;
5   begin
6     bmp := Tbitmap.Create;
7     try
8       bmp.width := listview1.width;
9       bmp.height := listview1.height;
10      with bmp.canvas do
11      begin
12        Lock;
13        try
14          listview1.perform(WM_PRINT, handle, PRF_CHILDREN or PRF_CLIENT or
15            PRF_NONCLIENT or PRF_ERASEBKGND);
16        finally
17          Unlock
18        end;
19        image1.picture.bitmap := bmp;
20      end;
21    finally
22      bmp.free
23    end;
24  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC