🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Is Printer able to...

#8848
From: Bob Gonder
Date: Fri, 10 Sep 2004 00:32
31 lines
2205 bytes
dcent wrote:

>Can anyone help with some code snippets to help me:
>1) Discover if a printer/driver is able to print double-sided.
>2) Set it to not print double-sided.
>3) Discover if the printer is a color printer.
>4) Set to B&W
>
>I have looked at the DeviceCapabilities() function, but can't figure out 
>how to get/set the port for a networked printer.

It's all in the DevMode.
Use DocumentProperties() 3 times:

1)With NULL for DevMode to get the size of the DEVMODE that you need.
num_bytes=DocumentProperties(NULL,printerHandle,&printerfile_port,NULL,NULL,0);
1a) Allocate a DEVMODE of that size.

2)Again, with the address of your newly allocated DevMode to get the
capabilities.
DocumentProperties(NULL,printerHandle,&printerfile_port,DevMode,NULL,DM_OUT_BUFFER);
2a)Check the bit patterns in  DevMode->dmFields for supported options.
2b)Set the various dmWhatever to single sided, B&W, etc.

3)Last time with the modified DevMode.
DocumentProperties(NULL,printerHandle,&printerfile_port,DevMode,DevMode,DM_OUT_BUFFER|DM_IN_BUFFER);

4)Then, use the returned DevMode from the 3rd call to create the
Printer DC that you will actually print on.

printerDC = CreateDC( NULL, &printerfile_port, NULL, DevMode); 
Technical Details
Message-ID: <brs1k05hfqplm6k1s6ogabnt90g522ng44@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4140DB66.7010709@NetScape.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,47dce7631b4e7cf9
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Is Printer able to...
Date: Thu, 09 Sep 2004 17:32:31 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <brs1k05hfqplm6k1s6ogabnt90g522ng44@4ax.com>
References: <4140DB66.7010709@NetScape.net>
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: 65.40.158.3
X-Trace: newsgroups.borland.com 1094776349 65.40.158.3 (9 Sep 2004 17:32:29 -0700)
Lines: 33
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail