🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15101

Re: TPrinter Problem

#15101
From: Anthony
Date: Tue, 15 Jul 2003 22:40
83 lines
3912 bytes
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: <3f148037@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-05!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f1460f3$1@newsgroups.borland.com> <3f14693d$1@newsgroups.borland.com> <3f1471c0$1@newsgroups.borland.com> <3f147649$1@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 15:40:03 PST
From: "Anthony" <endurokarter@yahoo.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>
Subject: Re: TPrinter Problem
Date: Tue, 15 Jul 2003 18:40:27 -0400
Lines: 85
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: <3f148037@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1058308151 24.128.134.183 (15 Jul 2003 15:29:11 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail