Print ListView1->Checkbox image to printer

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Print ListView1->Checkbox image to printer

Postby Smoke1 » Sat Nov 25, 2017 7:06 pm

Im using old Borland c++ builder 6.0 Enterprse suite..
how do I pass Listview1->Checkboxes to my printer?
VSReport mode.
This works great but I need to print check boxes
Current Printing Method..

TListItem *TelListItem;

if(PrintDialog1->Execute())
{

TPrinter * AddressList = Printer();
AddressList->BeginDoc();



AnsiString Col0 = ListView1->Column[0]->Caption;
AnsiString Col1 = ListView1->Column[1]->Caption;
AnsiString Col2 = ListView1->Column[2]->Caption;
AnsiString Col3 = ListView1->Column[3]->Caption;

int i, x;
String S("Diabetes");

AddressList->Canvas->Font->Size = 8;
AddressList->Canvas->Font->PixelsPerInch = 400;
x = AddressList->Canvas->TextHeight(S)-12; //14.5 this is important for page fix..


for(i = 0; i < ListView1->Items->Count; i++)
{
//Control Bottom of page
if ((i%(AddressList->PageHeight/x))== 0)
{
if(i!=0)
AddressList->NewPage();
}

TelListItem = Form1-> ListView1->Items->Item[i];


AddressList->Canvas->TextOutA(0,750, " "+ Col0+" "+Col1+" "+Col2+" "+Col3);

AddressList->Canvas->TextOut(100, (x* (i%(AddressList->PageHeight/x)))+x+900, TelListItem->Caption);
AddressList->Canvas->TextOut(790, (x*(i%(AddressList->PageHeight/x)))+x+900, TelListItem->SubItems->Strings[0]);
AddressList->Canvas->TextOut(1900, (x*(i%(AddressList->PageHeight/x)))+x+900, TelListItem->SubItems->Strings[1]);
AddressList->Canvas->TextOut(3950, (x*(i%(AddressList->PageHeight/x)))+x+900, TelListItem->SubItems->Strings[2]);


}
AddressList->EndDoc();

}
Last edited by Smoke1 on Sat Dec 02, 2017 5:42 pm, edited 2 times in total.
Smoke1
If you think education is difficult, try being stupid.
User avatar
Smoke1
BCBJ Veteran
BCBJ Veteran
 
Posts: 53
Joined: Sat Jan 21, 2012 12:03 pm
Location: Gainesville, Fla.

Re: passing ListView1->Checkboxes to printer

Postby rlebeau » Mon Nov 27, 2017 9:28 pm

Smoke1 wrote:how do I pass Listview1->Checkboxes to my printer?


I don't understand what you are asking for. Please clarify.

Are you asking how to print only items that are checked by the user? If so, then query the TListItem::Checked property inside your loop.

Or, do you want to render actual images of checkboxes? If so, then look at the Win32 API DrawFramedControl() function, or the DrawThemeBackground() function if your app is using visual styles.

BTW, you are doing a lot of redundant calculations in your code. You should cache those calculations in local variables.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: passing ListView1->Checkboxes to printer

Postby Smoke1 » Mon Nov 27, 2017 10:00 pm

i just wanted to actually print the image of the check box
like you see it listview form .

i know i have some cleaning on my print method code
I put it together fast but workable

i just havent been able to print the checkbox image
Ive not tried to print graphics before so this is all new to me,
and its listview, lol
Smoke1
If you think education is difficult, try being stupid.
User avatar
Smoke1
BCBJ Veteran
BCBJ Veteran
 
Posts: 53
Joined: Sat Jan 21, 2012 12:03 pm
Location: Gainesville, Fla.


Return to Technical

Who is online

Users browsing this forum: No registered users and 14 guests

cron