Article View: borland.public.cppbuilder.nativeapi
Article #15077Re: TPrinter Problem
From: Anthony
Date: Sat, 19 Jul 2003 18:17
Date: Sat, 19 Jul 2003 18:17
70 lines
3553 bytes
3553 bytes
Oh Fishface where were you two weeks ago.
This little piece of code fixes so many problems.
Printer->PrinterIndex = 1; { set to any non-default printer }
Printer->GetPrinter(Device, Driver, Port, hDMode);
Printer->SetPrinter(Device, Driver, Port, 0);
First it gets the correct Handle for the selected printer. Which then fixes
the page size information. Which is critical to all us out there trying to
print on different printers each with a different size paper. ie. Those of
us trying to print on address labels to a non-default printer who find that
the printer incessantly feeds 10 inches of paper between labels. The reason
is due to wrong handle equals worng page size information.
I thank all of those who have posted suggestions to solve my problem over
the last two weeks, including Gambit, JD, Vladimir, Alan, Bob, Hans, and
Midnight Programmer.
Thank you all.
"Fishface" <invalid@ddress.ok?> wrote in message
news:3f195e61@newsgroups.borland.com...
> Anthony wrote:
>
> > I tried the following test code:
> >
> > Printer()->PrinterIndex = index;
> > HPrinterDC=Printer()->Handle;
> > int width = GetDeviceCaps(HPrinterDC, PHYSICALWIDTH); // page size
x
> > in pixels
> > Printer()->BeginDoc();
> > HPrinterDC=Printer()->Handle;
> > width = GetDeviceCaps(HPrinterDC, PHYSICALWIDTH); // page size x
in
> > pixels
> >
> > HPrinterDC and width are the same before and after BeginDoc() is called.
It
> > would appear that the HDC is valid (incorrect but valid) before
BeginDoc()
> > is called.
>
> I am still using version 5, but nevertheless checked the source code. I
found
> something that didn't look right in the TPrinter::SetPrinterIndex()
PrinterIndex
> property setter function. I did a Google groups search as follows:
>
> group:*delphi* setprinterindex
>
> ...because there are more people using Delphi, and I never mind accepting
help from
> them! I found some interesting threads. The workaround for changing the
printer may
> involve something like the one shown in the "vcl\dialog
controls\tprintersetupdialog"
> link on this page:
>
> http://info.borland.com/devsupport/delphi/fixes/delphi4/vcl.html
>
> It looks like the problem has been around for quite a while. If they
can't fix something
> in five years or so, maybe they could at least get something into the help
files...
>
>
Technical Details
Message-ID:
<3f198cd1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f1460f3$1@newsgroups.borland.com> <3f14693d$1@newsgroups.borland.com> <3f1471c0$1@newsgroups.borland.com> <3f147649$1@newsgroups.borland.com> <3f148037@newsgroups.borland.com> <3f180395@newsgroups.borland.com> <3f1811af@newsgroups.borland.com> <3f195e61@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,d59131589fe63384 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-19 11:29:43 PST From: "Anthony" <awhitesell@attbi.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f1460f3$1@newsgroups.borland.com> <3f14693d$1@newsgroups.borland.com> <3f1471c0$1@newsgroups.borland.com> <3f147649$1@newsgroups.borland.com> <3f148037@newsgroups.borland.com> <3f180395@newsgroups.borland.com> <3f1811af@newsgroups.borland.com> <3f195e61@newsgroups.borland.com> Subject: Re: TPrinter Problem Date: Sat, 19 Jul 2003 14:17:24 -0400 Lines: 72 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 24.128.134.183 Message-ID: <3f198cd1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1058639057 24.128.134.183 (19 Jul 2003 11:24:17 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail