Article View: borland.public.cppbuilder.nativeapi
Article #12334Re: Windows Printers
From: John Scott
Date: Wed, 10 Dec 2003 16:31
Date: Wed, 10 Dec 2003 16:31
58 lines
3278 bytes
3278 bytes
This uis what I tried
// Nov 2003 to print double sided
char ADevice[256]={0}, ADriver[256]={0}, APort[256]={0};
THandle ADeviceMode;
Printer()->GetPrinter(ADevice, ADriver, APort, ADeviceMode);
LPDEVMODE DevMode=(LPDEVMODE)GlobalLock(ADeviceMode);
// error at line above was: Cannot convert 'unsigned int' to 'void *'
// also Type missmatch in 'hMem' (Wanted 'voud 8' gor 'unsigned int')
if (rgDuplex->ItemIndex==0) // Radio group to select duplex or simplex
{
DevMode->dmDuplex=DMDUP_VERTICAL;
DevMode->dmFields=DM_DUPLEX;
}
else
{
DevMode->dmDuplex=DMDUP_SIMPLEX;
}
Printer()->SetPrinter(ADevice, ADriver, APort, ADeviceMode);
// errors on line above:
// Type missmatch in parameter 'ADeviceMode'(wanted 'unsigned int', got
'unsigned int *')
// Cannot convert 'unsigned int' to 'void *'
GlobalUnlock(ADeviceMode);
// error in line above:
// Type missmatch in parameter 'hMem' (Wanted 'void *', got 'unsigned int
')
// end of add Nov 2003
I experimented and if I used:
LPDEVMODE DevMode=(LPDEVMODE)GlobalLock(&ADeviceMode);
and: GlobalUnlock(&ADeviceMode);
it compiled clean. Does that look correct?
Sorry to be so dim about this but I rarely do this type of code.
>
> 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:
<3fd74ac6@newsgroups.borland.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> <r2jctvg3ob96k02d4lmdh0td3eascnm0bt@4ax.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-10 08:39:57 PST From: "John Scott" <jscott@kw.igs.net> Newsgroups: borland.public.cppbuilder.nativeapi 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> <r2jctvg3ob96k02d4lmdh0td3eascnm0bt@4ax.com> Subject: Re: Windows Printers Date: Wed, 10 Dec 2003 11:31:57 -0500 Lines: 60 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: 216.16.227.114 Message-ID: <3fd74ac6@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071073990 216.16.227.114 (10 Dec 2003 08:33:10 -0700) 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