🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Windows Printers (Bob Gonder please respond)

#12226
From: Bob Gonder
Date: Tue, 16 Dec 2003 23:37
79 lines
3717 bytes
John Scott wrote:

>Hi Bob: I tried the code at my clients and it did not work. The code I tried

My last message to you mentioned that it probably wouldn't.
I've already posted several times what the API code is to get the job
done.  I really have no clue how the VCL handles all this. (The people
in vcl.components.using probably do though.)

Since you can't test Duplex in-house, why don't you try to change
DM_ORIENTATION via the DEVMODE?  Once you get that working in-house,
adding DM_DUPLEX should be trivial.

>    GlobalUnlock(&ADeviceMode);
>
>do not use the &. Your instructions did not have the & but if I leave it out
>It generated errors when I compile.

That's because the documentation quote you gave which led me to
suggest that tact was incorrect.  Had the quote been correct, the code
would have compiled as written.  The fact that it didn't compile, led
me to look up the function myself, and that showed a  different set of
parameters, which agreed with the errors you cited.

Once again, the steps:

1) Get the Printer Handle
HANDLE PrinterHandle = Print->???? /*VCL interface*/
	I use this instead of the VCL:
	OpenPrinter(&printerfile_port,&printerHandle,NULL); (see docs)

2) Get the Size of the DevMode for *this* printer.
unsigned num_bytes = DocumentProperties(NULL, PrinterHandle,
				&printerfile_port, NULL, NULL, 0);

3) Get some (clean) memory for the DevMode
DEVMODE*DevMode = (DEVMODE*)GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT,
					num_bytes );

4) Read the existing DevMode
DocumentProperties(NULL, PrinterHandle, &printerfile_port,
			DevMode, NULL, DM_OUT_BUFFER);

5) Check if the feature you want is available (not 100% sure of this)
if( DevMode->dmFields & DM_DUPLEX )	/* if duplex is available */

6) Modify the fields
DevMode->dmOrientation = DMORIENT_LANDSCAPE;

7) Specify which fields we are setting
DevMode->dmFields = DM_ORIENTATION ;

8) Tell Windows about our changes, and get back the final fully loaded
DevMode:
DocumentProperties(NULL, PrinterHandle, &printerfile_port, DevMode, 
		DevMode, DM_OUT_BUFFER | DM_IN_BUFFER);

9) Use the final DevMode to create the PrinterDC
I don't know if you need to do this for the VCL, or if or how the VCL
handles it.
HDC printerDC = CreateDC( NULL, &printerfile_port, NULL, DevMode); 

10) Release our memory
GlobalFree(DevMode);

And to complete:
11) Print a page
	StartPage(printerDC);
	SetTextAlign(printerDC,TA_LEFT+TA_TOP+TA_NOUPDATECP);
	SetBkMode (printerDC, TRANSPARENT);

DeleteObject(SelectObject(printerDC,(HGDIOBJ)CreateFont(...)));
	ExtTextOut(printerDC......);
	EndPage(printerDC);

12) Close
	EndDoc(printerDC);
	DeleteDC(printerDC);
	ClosePrinter(PrinterHandle);
Technical Details
Message-ID: <lb1vtv00s6mqf5mlqkraou7v3rir2lvlcr@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-mail
References: <3fdf3f3b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,db79f85f5b525ea6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-16 15:39:52 PST
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Windows Printers (Bob Gonder please respond)
Date: Tue, 16 Dec 2003 15:37:25 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <lb1vtv00s6mqf5mlqkraou7v3rir2lvlcr@4ax.com>
References: <3fdf3f3b@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.164.98
X-Trace: newsgroups.borland.com 1071617853 67.31.164.98 (16 Dec 2003 15:37:33 -0700)
Lines: 81
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