Page 1 of 1

Print ListView1->Checkbox image to printer

PostPosted: Sat Nov 25, 2017 7:06 pm
by Smoke1
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();

}

Re: passing ListView1->Checkboxes to printer

PostPosted: Mon Nov 27, 2017 9:28 pm
by rlebeau
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.

Re: passing ListView1->Checkboxes to printer

PostPosted: Mon Nov 27, 2017 10:00 pm
by Smoke1
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