Article View: borland.public.cppbuilder.nativeapi
Article #12513Re: Windows Printers
From: Bob Gonder
Date: Tue, 09 Dec 2003 22:59
Date: Tue, 09 Dec 2003 22:59
38 lines
2820 bytes
2820 bytes
John Scott wrote:
>In my case this won't be a big problem. The printer is exclusively used for
>printing these cards, but it would be better if I were to control it.
>Here is what I understand I should be trying to do.
>1. I need to create a DEVMODE structure in memory.
>2. Get the Handle (is this the pointer to the structure?) of the DEVMODE
>3. Then the Printer()->GetPrinter() will fill the structure with the current
>values.
>4. I would then set the specific values as necessary.
>5. Then use Printer()->SetPrinter() to apply the new values to the printer.
>6. Release the memory used for the DEVMODE
>
>Now I usually use the new operator to create objects in memory so would:
>
>DEVMODE *DeviceMode;
>DeviceMode=new DEVMODE;
>
>would this create the structure in memory as you are doing with
>GlobalAlloc()
No.
THandle ADeviceMode;
Printer()->GetPrinter(ADevice, ADriver, APort, ADeviceMode);
returns the HANDLE ADeviceMode.
HANDLES are NOT addresses.
Turn the Handle into an address:
LPDEVMODE DevMode = (LPDEVMODE)GlobalLock(ADeviceMode);
Use the DEVMODE:
DevMode->dmDuplex = DMDUP_VERTICAL;
DevMode->dmFields = DM_DUPLEX;
GlobalUnlock(ADeviceMode);
Printer()->SetPrinter();
I don't know if you need to unlock before or after the SetPrinter.
Also don't know if you need to GlobalFree the handle, or if the VCL
handles that. (VCL hides too much, that's one reason I don't use it)
Technical Details
Message-ID:
<r2jctvg3ob96k02d4lmdh0td3eascnm0bt@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fcb2567$1@newsgroups.borland.com> <3fcb6984@newsgroups.borland.com> <goumsvolftvangoh1n8i7ktptavi57ut2d@4ax.com> <dsvmsvo53afn3qqk6p2ir6ld5lldimucju@4ax.com> <3fcb93d8@newsgroups.borland.com> <eipnsvs99q92prau97tl685lua6crv6e92@4ax.com> <3fce1fed@newsgroups.borland.com> <eudssvci6j3q0l82ivvfs5oj3i2rn1c5ct@4ax.com> <3fcf5268$1@newsgroups.borland.com> <3fd4b3a4@newsgroups.borland.com> <tvr9tv4cctvuri7np179a37t666i9m1s5u@4ax.com> <3fd5ece9@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7b2449597708bec X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-09 15:09:32 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Windows Printers Date: Tue, 09 Dec 2003 14:59:34 -0800 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <r2jctvg3ob96k02d4lmdh0td3eascnm0bt@4ax.com> References: <3fcb2567$1@newsgroups.borland.com> <3fcb6984@newsgroups.borland.com> <goumsvolftvangoh1n8i7ktptavi57ut2d@4ax.com> <dsvmsvo53afn3qqk6p2ir6ld5lldimucju@4ax.com> <3fcb93d8@newsgroups.borland.com> <eipnsvs99q92prau97tl685lua6crv6e92@4ax.com> <3fce1fed@newsgroups.borland.com> <eudssvci6j3q0l82ivvfs5oj3i2rn1c5ct@4ax.com> <3fcf5268$1@newsgroups.borland.com> <3fd4b3a4@newsgroups.borland.com> <tvr9tv4cctvuri7np179a37t666i9m1s5u@4ax.com> <3fd5ece9@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.31.166.32 X-Trace: newsgroups.borland.com 1071010779 67.31.166.32 (9 Dec 2003 14:59:39 -0700) Lines: 43 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail