Article View: borland.public.cppbuilder.nativeapi
Article #15107Re: TPrinter Problem
From: Anthony
Date: Wed, 16 Jul 2003 00:29
Date: Wed, 16 Jul 2003 00:29
112 lines
4446 bytes
4446 bytes
To all,
JD has reminded of the solution:
char Device[ 256 ] = { 0 };
char Driver[ 256 ] = { 0 };
char Port[ 256 ] = { 0 };
THandle hDeviceMode;
Printer()->PrinterIndex = pIndex;
Printer()->GetPrinter( Device, Driver, Port, hDeviceMode );
Thanx.
"Anthony" <endurokarter@yahoo.com> wrote in message
news:3f148037@newsgroups.borland.com...
> Gambit,
>
> To answer your questions:
>
> I was getting the wrong page sizes with:
> (A)
> Printers()->PrinterIndex=x;
> width=GetDeviceCaps(Printers()->Handle, PHYSICALWIDTH);
>
> which was corrected when I did:
> (B)
> HDC HPrinterDC = CreateDC(NULL, Device.c_str(), NULL, pdm);
> width=GetDeviceCaps(HPrinterDC, PHYSICALWIDTH);
>
> or:
> (C)
> HDC HPrinterDC = CreateIC(NULL, Device.c_str(), NULL, pdm);
> width=GetDeviceCaps(HPrinterDC, PHYSICALWIDTH);
>
> which lead me to notice that the Handle returned by (A) was not the same
as
> returned by (B) or (C) when accessing a printer that is other than the
> default printer.
>
> I tried CreateDC because in was already coded from an example I was lead
to
> by another poster Vladimir. I tried both for the heck of it; what's the
> difference?
>
>
> The application:
>
> The application needs to print on three different printers, one is
portrait
> letter text , the second is landscape letter graphic, and the third (where
> the problem is most obvious) prints on one of three sizes of continuous
feed
> address labels. The first two are laser or bubble jet printers, the third
> is a dot matrix printer with tractor feed.
>
> And the problem: (which I have spent the better part of the week on)
>
> I have the first two woking fine, but the problem started when I was
trying
> to get the page size for the label printer using (A) from above. I
finally
> was able to get the page size corrected using GetDeviceCaps if I manually
> changed the default printer (which isn't practical in the end
application).
>
> The issue of having the wrong handle was masked by the fact that I was
> selecting and printing to the correct printer but on the wrong size paper.
> So, prior to realizing the handle was wrong I figured that the page size
was
> not getting from the printer settings to GetDeviceCaps and starting
looking
> for a way to set the page size in the program.
>
> Now that I know the TPrinter::Handle is wrong, can (A) be fixed or do I
have
> to go with (B) or (C)?
>
> Thank you for your time.
> Anthony
>
>
>
> "Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
> news:3f147649$1@newsgroups.borland.com...
> >
> > "Anthony" <awhitesell@attbi.com> wrote in message
> > news:3f1471c0$1@newsgroups.borland.com...
> >
> > > I can use both
> > >
> > > HDC HPrinterDC = CreateDC(NULL, Device.c_str(), NULL, pdm);
> > > and
> > > HDC HPrinterDC = CreateIC(NULL, Device.c_str(), NULL, pdm);
> >
> > I didn't say to use CreateDC(). That is a different matter.
> >
> > > and get the correct page sizes.
> >
> > What does page sizes have to do with anything? You said you were
> receiving
> > the same HDC when using Printer()->Handle? Or did I misread what you
said
> > originally? Please clearify EXACTLY what you are trying to do and what
> > EXACTLY is not working correctly.
> >
> >
> > Gambit
> >
> >
>
>
Technical Details
Message-ID:
<3f149de5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!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>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-15 17:39:53 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> Subject: Re: TPrinter Problem Date: Tue, 15 Jul 2003 20:29:01 -0400 Lines: 114 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: <3f149de5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1058315749 24.128.134.183 (15 Jul 2003 17:35:49 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail