🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Is Printer able to...

#8861
From: Bob Gonder
Date: Sun, 12 Sep 2004 05:10
43 lines
2471 bytes
dcent wrote:

>Bob Gonder wrote:
>> It's all in the DevMode.
>> Use DocumentProperties() 3 times:

Forgot to mention  this before any of the DocumentProperties() calls
	if(  OpenPrinter(&printerfile_port,&printerHandle,NULL) )
 
>> 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.
>
>Where/How do I get the &printerfile_port information from the currently 
>selected, not default, printer?

I have the user store them in a file so I don't have to mess with all
that.  I can show you how I give the user the info for what the valid
portnames are:

char	buffer[16*1024];
PRINTER_INFO_1 *pinfo = buffer;

if( EnumPrinters( PRINTER_ENUM_LOCAL,0,	1, buffer,
		16*1024,	&bytes, &copies)	 )
	while( copies)
	{	lstrcpyn( que.Buffer, pinfo->pName, 64 );
		copies--;
		pinfo++;
		que.Append();
	};
Ignore what a que is.
I hard coded the que buffer to 64 char, that's why the lstrcpyn

I suppose that means your answer is in
PRINTER_INFO_1->pName
Now you just have to figure out how you are going to get it.
What did you use to let the user select a printer?
Those usually return a PRINTER_INFO_n

If you are using PrintDlg(), then look at the returned hDevMode and
hDevNames. They are handles, so you need to use GlobalLock() to get
the memory addresses.
Technical Details
Message-ID: <vak7k0d1fjstjc7e49hstkciv1a7l01p1p@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4140DB66.7010709@NetScape.net> <brs1k05hfqplm6k1s6ogabnt90g522ng44@4ax.com> <41431608.6030503@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: Sat, 11 Sep 2004 22:10:32 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <vak7k0d1fjstjc7e49hstkciv1a7l01p1p@4ax.com>
References: <4140DB66.7010709@NetScape.net> <brs1k05hfqplm6k1s6ogabnt90g522ng44@4ax.com> <41431608.6030503@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.245.82
X-Trace: newsgroups.borland.com 1094965828 65.40.245.82 (11 Sep 2004 22:10:28 -0700)
Lines: 46
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail