Results 1 to 5 of 5

Thread: Hard question: Set Printer settings by api

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    81

    Hard question: Set Printer settings by api

    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.
    -------------------------
    There is never only one right answer. That is the magic of programming.
    -------------------------

  2. #2
    jim mcnamara
    Guest
    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.

    Code:
    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

  3. #3
    jim mcnamara
    Guest
    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

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    81

    Thanks

    The printer is a HP 6p.

    I appricate the help.

    I also notice, that the application.printout collate:=true fuction is about useless
    -------------------------
    There is never only one right answer. That is the magic of programming.
    -------------------------

  5. #5
    jim mcnamara
    Guest
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width