BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

print the content of a listview

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Jani Ruohomaa
Guest





PostPosted: Mon Nov 01, 2004 3:24 pm    Post subject: print the content of a listview Reply with quote



Hi!

How do you print the content of a listview to a printer ?

Jani


Back to top
Jani Ruohomaa
Guest





PostPosted: Wed Nov 03, 2004 4:38 pm    Post subject: Re: print the content of a listview Reply with quote



Hi!

Basically I have 4 listviews on a form that I want to print with headings
etc. On another form I have the same problem and there can be several
hundred entries in 1 listview
It seems to be quite difficult.... Your solution does the job but I'm not
sure that it is the best possible solution (no offence)

I have to keep on trying...

Jani

"Vladimir Stefanovic" <spam (AT) not (DOT) needed> wrote

Quote:
Hi,

You probably think to print when ListView is in
Report style.

A couple days ago I made one quick version for
myself. I told you this because my code is not
based on any known example so it is a scratch
that probably should be corrected in some parts:


This is it:
(the argument is switcher if to print all items or only
selected items)

void TLanMsgMainForm::PrintItems( bool Selected )
{
ListView->Enabled = false;
int margin_pixels = 30;
Printer()->BeginDoc();
if ( Selected )
Printer()->Title = "Printing selected...";
else
Printer()->Title = "Printing all...";

Printer()->Canvas->Font->Name = "Terminal";
Printer()->Canvas->Font->Size = 9;
Printer()->Canvas->Font->Charset = EASTEUROPE_CHARSET;
Printer()->Canvas->Font->Pitch = fpFixed;

int line = 0;
int real_line = 0;

for ( int i=0; i<ListView->Items->Count; i++ )
{
if ( Selected && !ListView->Items->Item[i]->Selected )
continue;

++line;
++real_line;

AnsiString LineToPrint =
Format( "%4s.%4s%10s%12s%11s%10s%25s%30s",
ARRAYOFCONST(( (IntToStr(real_line)),

(ListView->Items->Item[i]->SubItems->Strings[0]),

(ListView->Items->Item[i]->SubItems->Strings[1]),

(ListView->Items->Item[i]->SubItems->Strings[2]),

(ListView->Items->Item[i]->SubItems->Strings[3]),

(ListView->Items->Item[i]->SubItems->Strings[4]),

(ListView->Items->Item[i]->SubItems->Strings[5]),

(ListView->Items->Item[i]->SubItems->Strings[6]) )) );

int TH = Printer()->Canvas->TextHeight( LineToPrint );
int top = margin_pixels + ( line * TH );

if ( ( top + 2*margin_pixels + TH ) >= Printer()->PageHeight )
{
Printer()->NewPage();
line = 1;
top = margin_pixels + ( line * TH );
}

Printer()->Canvas->TextOut( margin_pixels, top, LineToPrint );
}

Printer()->NewPage();
Printer()->EndDoc();
ListView->Enabled = true;
}



Best regards,
Vladimir Stefanovic

Jani Ruohomaa <jani.ruohomaa (AT) kolumbus_poista (DOT) fi> wrote in message
news:41865558$6 (AT) newsgroups (DOT) borland.com...
Hi!

How do you print the content of a listview to a printer ?

Jani







Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.