Article View: borland.public.cppbuilder.nativeapi
Article #12480Re: Windows Printers
From: John Scott
Date: Mon, 08 Dec 2003 17:22
Date: Mon, 08 Dec 2003 17:22
86 lines
4570 bytes
4570 bytes
I wonder if this stuff is necessary. If the printer has the duplex capability and it is enabled then why would I need to use this process to change the setting - it will already be enabled! I think I will just experiment with teh NewPage(), StartPage() EndPage() techniques John "John Scott" <jscott@kw.igs.net> wrote in message news:3fcf5268$1@newsgroups.borland.com... > I guess I was confused. The help for the TPrinter object shows the > GetPrinter() method as using a pointer to a DEVMODE as the last parameter. > Retrieves information about the current printer. > > void __fastcall GetPrinter(char * ADevice, char * ADriver, char * APort, int > &ADeviceMode); > > Description > > Call GetPrinter to obtain information about the current printer. > > ADevice is a buffer that receives the device name of the current printer. > This is the name that appears in the Print Manager (for example, "Epson > FX-80"). It is not the printer model name. > > ADriver is a buffer that receives the driver name for the current printer. > Some versions of Windows do not use printer driver names, in which case this > buffer is unused. On versions of Windows that support printer driver names, > this is the name of a printer driver (usually ' > WINSPOOL'). > > APort is a buffer that receives the port used by the current printer. It is > not used on 32-bit versions of Windows, but is included for backward > compatibility. > > DeviceMode returns the handle to a memory buffer containing a DEVMODE > structure, which contains device-specific initialization data for the device > driver. Use the GlobalLock function to convert this handle into a pointer to > the structure. > > I Guess I need to explore that GlobalLock function. I want to stick with the > VCL as much as possible since the existing code is VCL. > > > > I have no idea what GetPrinter() does (I don't do VCL), but it is > > obvious that ADeviceMode is a THandle, not a DEVMODE. > > > > AS I posted before, you need to use DocumentProperties() or the VCL > > equiv. to get/set the devmode. > > > > num_bytes = DocumentProperties(NULL, printerHandle, &printerfile_port, > > NULL, NULL, 0); > > DevMode = (DEVMODE*)GlobalAlloc( GMEM_FIXED |GMEM_ZEROINIT,num_bytes); > > DocumentProperties(NULL, printerHandle, &printerfile_port, DevMode, > > NULL, DM_OUT_BUFFER); > > // modify the appropriate fields > > DevMode->dmFields = DM_ORIENTATION | DM_PRINTQUALITY ; > > DevMode->dmOrientation = printer_direction=='L'? DMORIENT_LANDSCAPE: > > DMORIENT_PORTRAIT; > > DevMode->dmPrintQuality = DMRES_HIGH; > > // call DocumentProperties() yet again, this time to get the > > final DEVMODE to pass into the CreateDC() function > > DocumentProperties(NULL, printerHandle, &printerfile_port, DevMode, > > DevMode, DM_OUT_BUFFER | DM_IN_BUFFER); > > // create a printer device context > > printerDC = CreateDC( NULL/*Driver.c_str()*/, &printerfile_port, NULL, > > DevMode); > > GlobalFree(DevMode); > > > > > > >One final thing how does Printer()->NewPage; differ from the StartPage() > and > > >EndPage()? > > > > Don't know, but it probably calls them. > > > > > >
Technical Details
Message-ID:
<3fd4b3a4@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fbcf9c2@newsgroups.borland.com> <3fbd8132$1@newsgroups.borland.com> <3fc77301@newsgroups.borland.com> <3fc7e524$1@newsgroups.borland.com> <3fca2474@newsgroups.borland.com> <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>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-08 09:29:30 PST From: "John Scott" <jscott@kw.igs.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fbcf9c2@newsgroups.borland.com> <3fbd8132$1@newsgroups.borland.com> <3fc77301@newsgroups.borland.com> <3fc7e524$1@newsgroups.borland.com> <3fca2474@newsgroups.borland.com> <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> Subject: Re: Windows Printers Date: Mon, 8 Dec 2003 12:22:38 -0500 Lines: 88 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.118 Message-ID: <3fd4b3a4@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1070904228 216.16.227.118 (8 Dec 2003 09:23:48 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail