 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
choykw Guest
|
Posted: Thu Feb 09, 2006 7:03 am Post subject: yet another TPrinter odd behavior |
|
|
Hi,
I was testing/tuning the report printing of one of my apps, and since the
printer I used for testing, an inkjet printer, has its black cartridge
damaged, I set the printing to some color (clAqua in this case). The report
is pretty long, and contains some stationaries like borders and
header/footer. The problem lies with the borders in particular.
I have set the border to pen width of 5, pen color to clAqua. The first page
it came out correct, 5 pixels line in Cyan color. However, as soon as the
2nd page came out, I noticed the borders are all missing! After fiddling
with the setting and my code, I'm frustrated and pulled out a record printed
previously by my client, they are using a laser printer and the borders are
all present in the reports. However I noticed the line width seems very thin
starting on the 2nd pages onward, for all the reports.
So, what I figured out is, the TPrinter will disregard my Pen Setting on the
Canvas and revert back to the default (Pen Width 1 and Pen Color clBlack) as
soon as I called TPrinter->NewPage();
This is how my code look like:
void __fastcall TForm1::PrintButtonClick(TObject *Sender)
{
//printer is a TPrinter* defined in the header with
//the scope to cover the whole TForm1
printer = Printer();
//....calculate the geometry for printing base on info
//returned from the printer, mainly converting
//printer's canvas pixels unit to measurable unit like
//pixel per milimeter, setup the formatting etc...
printer->BeginDoc();
DrawStationaries();
for(int i=0; i<totalLines; i++)
{
//draw the text on the Canvas line by line
//with Canvas->TextOutA(...)
//each page contains 50 lines
if((i%50) == 0 && i > 0)
{
printer->NewPage();
DrawStationaries();
//reset the printing location to the top of the page
}
}
printer->EndDoc();
}
and in the DrawStationaries():
void __fastcall TForm1::DrawStationaries(void)
{
printer->Canvas->Pen->Style = psSolid;
printer->Canvas->Pen->Width = 5;
printer->Canvas->Pen->Color = clAqua;
printer->Canvas->Rectangle(rectangle); //a TRect
//....other things like more rectangles and print
//some text...
}
so, is there anything wrong in the code above that caused the pen to revert
back to default? How do I make sure the pen always draw at the setting I
chosen? I have already re-configure the setting every time I issued a
NewPage() with the printer. Please help. Thanks in advance.
Regards. |
|
| Back to top |
|
 |
choykw Guest
|
Posted: Sat Feb 11, 2006 3:03 am Post subject: Re: yet another TPrinter odd behavior |
|
|
"choykw" <blue (AT) blue (DOT) com> 撰寫於郵件新聞:43eae17a$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi,
I was testing/tuning the report printing of one of my apps, and since the
printer I used for testing, an inkjet printer, has its black cartridge
damaged, I set the printing to some color (clAqua in this case). The
report is pretty long, and contains some stationaries like borders and
header/footer. The problem lies with the borders in particular.
I have set the border to pen width of 5, pen color to clAqua. The first
page it came out correct, 5 pixels line in Cyan color. However, as soon as
the 2nd page came out, I noticed the borders are all missing! After
fiddling with the setting and my code, I'm frustrated and pulled out a
record printed previously by my client, they are using a laser printer and
the borders are all present in the reports. However I noticed the line
width seems very thin starting on the 2nd pages onward, for all the
reports.
So, what I figured out is, the TPrinter will disregard my Pen Setting on
the Canvas and revert back to the default (Pen Width 1 and Pen Color
clBlack) as soon as I called TPrinter->NewPage();
This is how my code look like:
void __fastcall TForm1::PrintButtonClick(TObject *Sender)
{
//printer is a TPrinter* defined in the header with
//the scope to cover the whole TForm1
printer = Printer();
//....calculate the geometry for printing base on info
//returned from the printer, mainly converting
//printer's canvas pixels unit to measurable unit like
//pixel per milimeter, setup the formatting etc...
printer->BeginDoc();
DrawStationaries();
for(int i=0; i<totalLines; i++)
{
//draw the text on the Canvas line by line
//with Canvas->TextOutA(...)
//each page contains 50 lines
if((i%50) == 0 && i > 0)
{
printer->NewPage();
DrawStationaries();
//reset the printing location to the top of the page
}
}
printer->EndDoc();
}
and in the DrawStationaries():
void __fastcall TForm1::DrawStationaries(void)
{
printer->Canvas->Pen->Style = psSolid;
printer->Canvas->Pen->Width = 5;
printer->Canvas->Pen->Color = clAqua;
printer->Canvas->Rectangle(rectangle); //a TRect
//....other things like more rectangles and print
//some text...
}
so, is there anything wrong in the code above that caused the pen to
revert back to default? How do I make sure the pen always draw at the
setting I chosen? I have already re-configure the setting every time I
issued a NewPage() with the printer. Please help. Thanks in advance.
Regards.
|
Hmm...no answer? Even from TeamB? |
|
| Back to top |
|
 |
JD Guest
|
Posted: Sat Feb 11, 2006 3:03 pm Post subject: Re: yet another TPrinter odd behavior |
|
|
"choykw" <blue (AT) blue (DOT) com> wrote:
Please trim your posts.
| Quote: | Hmm...no answer? Even from TeamB?
|
I looked at this when it was first posted and saw nothing
wrong with the code that you posted (but you didn't post
everything). If you want further assistance, you need to
create a sample project (with test data) that demonstrates
the problem and post it to the attachments group.
~ JD |
|
| Back to top |
|
 |
choykw Guest
|
Posted: Mon Feb 13, 2006 3:03 am Post subject: Re: yet another TPrinter odd behavior |
|
|
"JD" <nospam (AT) nospam (DOT) com> 撰寫於郵件新聞:43edf676$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I looked at this when it was first posted and saw nothing
wrong with the code that you posted (but you didn't post
everything). If you want further assistance, you need to
create a sample project (with test data) that demonstrates
the problem and post it to the attachments group.
~ JD
|
The parts I omitted are just some data, which I deem not important to the
problem, those are simple SQL query from the database and some TextOutA()
calls, nothing have to do with any printer setting. I'm not sure how I could
utilize the attachment group, but I'll see what I can do once I have time. |
|
| Back to top |
|
 |
choykw Guest
|
Posted: Mon Feb 13, 2006 4:03 am Post subject: Re: yet another TPrinter odd behavior |
|
|
"choykw" <blue (AT) blue (DOT) com> 撰寫於郵件新聞:43eff1a6 (AT) newsgroups (DOT) borland.com...
| Quote: | The parts I omitted are just some data, which I deem not important to the
problem, those are simple SQL query from the database and some TextOutA()
calls, nothing have to do with any printer setting. I'm not sure how I
could utilize the attachment group, but I'll see what I can do once I have
time.
|
I have posted the program code to the attachement group as requested, with
the title "sample program of TPrinter odd behavior"
Thanks for helping |
|
| Back to top |
|
 |
JD Guest
|
Posted: Mon Feb 13, 2006 9:03 am Post subject: Re: yet another TPrinter odd behavior |
|
|
"choykw" <blue (AT) blue (DOT) com> wrote:
| Quote: |
[...] I have posted the program code [...]
|
As is the case with most, I don't do .rar. .zip should be your
firtst choice and ascii (.txt) your second.
~ JD |
|
| Back to top |
|
 |
|
|
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
|
|