PDA

Click to See Complete Forum and Search --> : Hard question: Set Printer settings by api


BHostmeyer
Sep 10th, 2001, 10:31 AM
I can find 500 ways to get settings from a print driver... but how do i set the settings.

I need to be able to turn on Collating..

have tried collate:=true didnt work
have tried

pDevMode.dmCollate = DMCOLLATE_TRUE
Call CopyMemory(pDevMode, aDevMode(1), Len(pDevMode))
using the Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
ByVal pDefault As Long) As Long

That worked some times but not every time. maybe 1 out of 3. after i call copy memory and do a check settings it is still turned off.

if anyone can help or offer suggestions please drop me a line.

jim mcnamara
Sep 10th, 2001, 01:51 PM
If you know the actual code to set collating sequence you can send it to the printer with the escape api. Escape bypasses GDI.
Then print whatever you want.


Declare Function Escape Lib "gdi32" Alias "Escape" ( _
ByVal hdc As Long, _
ByVal nEscape As Long, _
ByVal nCount As Long, _
ByVal lpInData As String, _
lpOutData As Any _
) As Long

dim mySeq as string
mySeq = chr(27) & "AD6G" ' I made this up for the example

Const PASSTHROUGH = 19
' passthrough is just that: let all data passthru unharmed.

call Escape(Printer.hDC,PASSTHROUGH, Len(mySeq), mySeq, vbNull)
Printer.Print mydata
Printer.EndDoc

jim mcnamara
Sep 10th, 2001, 04:15 PM
Go to the printer programming manual. There will be a list of control codes. They DO NOT make sense like 'COLLATE'.
It will most likely be either HP PCL or postscript.
Escape is for these kinds of things. 'COLLATE' is strictly something that VB knows about. The printer doesn't understand that language.

Tell us what the printer is, please. I have PCL manuals at home.

I KNOW just sending a '16' to any printer doesn't make it decide to collate. That is something internal to windows or VB.

PCL commands start with ascii 27 - the escape character.
PostScript looks like a programming language written by a madman. like: d{10 10 lineto 99 rotate roll pop}/def

BHostmeyer
Sep 10th, 2001, 04:57 PM
The printer is a HP 6p.

I appricate the help.

I also notice, that the application.printout collate:=true fuction is about useless

jim mcnamara
Sep 10th, 2001, 09:16 PM
Part 1: look up job control settings in your HP 6P manual, there is probably one that does all this crud. My manuals go to PCL 5.

Here are some my manuals have:

They ALL start with chr(27) - escape

Select input drawer (eg., for alternating colored & white a paper)
&l#G and 1 or 2, esc&l#G1 esc&l#G2

select input (uses 1 to 6) esc&lH plus 1, 2, 3.....

job separator page - esc&llT

left & right registration (can shift some trays)

esc&l#U esc&l#Z


Have fun.