Article View: borland.public.cppbuilder.nativeapi
Article #1678Re: More on Dialogs
From: JD
Date: Thu, 28 Jun 2007 21:38
Date: Thu, 28 Jun 2007 21:38
72 lines
3299 bytes
3299 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>> It is my current understanding that one must first set the
>> PrinterIndex before one calls SetPrinter.
>
> Then your understanding has been misled.
From a post by Damon:
if( PageSetupDlg(&psd) )
{
HANDLE HMem;
char device[MAX_PATH], driver[MAX_PATH], port[MAX_PATH];
Printer()->GetPrinter(device, driver, port, (int)HMem);
Printer()->SetPrinter(device, driver, port, (int)psd.hDevMode);
// do some printing...
GlobalFree(HMem);
GlobalFree(psd.hDevNames);
}
and that wasn't working until I added setting the PrinterIndex.
> TPrinter::SetPrinter() assigns the PrinterIndex (amongst
> other things) based on the structures that are passed to
> it.
Thanks. It's working fine now and the TDialogs respect the
currently selected printer even if an API dialog selected it
but I'm still working on getting the API dialogs to respect
it (they open with the default printer).
>> [...] but I just found this in the docs for PRINTDLGEX:
>
> The VCL dialogs do not use PRINTDLGEX.
True, but they do use DEVNAMES.
>> Obviousely there's an error there
>
> There is not.
The docs for DEVNAMES wDeviceOffset says (in part):
[...] (maximum of 32 bytes including the null) [...]
This string must be identical to the dmDeviceName member
of the DEVMODE structure.
However, not only does PRINTDLGEX contradict that, so does
PAGESETUPDLG:
If both hDevNames and hDevMode have valid handles and the
printer name specified by the wDeviceOffset member of the
DEVNAMES structure is not the same as the name specified
by the dmDeviceName member of the DEVMODE structure, the
system uses the name specified by wDeviceOffset by default.
They can't both be correct (unless there are different rules
for input and output) but that's a moot point now. It just
added to the confusion.
>> Don't I need to dispose of the TPrinter's current DEVMODE?
>
> No. That is handled automatically inside of TPrinter::SetPrinter().
Good to know.
Thanks.
~ JD
Technical Details
Message-ID:
<46842a5a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news2.euro.net!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46825ff3@newsgroups.borland.com> <46829422$1@newsgroups.borland.com> <46836c01@newsgroups.borland.com> <46837feb$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,964b3d9a83e56201 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "JD" <nospam@nospam.com> From: "JD" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <46825ff3@newsgroups.borland.com> <46829422$1@newsgroups.borland.com> <46836c01@newsgroups.borland.com> <46837feb$1@newsgroups.borland.com> Subject: Re: More on Dialogs Date: Thu, 28 Jun 2007 16:38:32 -0500 Lines: 74 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 172.147.243.220 Message-ID: <46842a5a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1183066714 172.147.243.220 (28 Jun 2007 14:38:34 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news2.euro.net!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail