please dont rip this site

Note: 0019 03/13/97  Printing form images from printer-resident form storage in a programming language (e.g. Visual Basic.)

Some Windows printer drivers and some Windows-oriented languages will not allow the PCL escape character pass-through to the printer since it is not a printable character in the Windows font set. (Visual Basic and the HP LaserJet III printer driver from the Windows for Workgroups disks are examples) The HP LaserJet III printer driver from the Windows 3.1 disks and the HP LaserJet 4 printer drivers do not have this problem unless used with a language like Visual Basic which causes the escape character to be removed on any printer driver. The Windows API contains a function specifically designed to avoid this problem by allowing the programmer to send any codes through the printer driver and the language that is sending data to the printer driver without interference. This API function is defined as follows:

 short Escape(hdc,PASSTHROUGH, NULL, lpInData, NULL)

 The PASSTHROUGH printer escape allows the application to send data directly to the printer, bypassing the standard print-driver code.

 Note: To use this escape, an application must have complete information about how the particular printer operates.

 ParameterDescription

PASSTHROUGH This function ID has a constant value of 19.

hdcHDC Identifies the device context.

lpInDataLPSTR Points to a structure whose first word (16 bits) contains the number of bytes of input data. The remaining bytes of the structure contain the data itself.

  Returns

The return value specifies the number of bytes transferred to the printer if the escape is successful. This value is less than or equal to zero if the escape is not successful or not implemented.

  Errors

If the function fails, the return value is one of the following:

 ValueMeaning

SP_ERRORGeneral error.

SP_OUTOFDISKNot enough disk space is currently available for spooling, and no more space will become available.

SP_OUTOFMEMORYNot enough memory is available for spooling.

SP_USERABORTUser terminated the job through Print Manager.

  Comments

There may be restrictions on the kinds of device data an application can send to the device without interfering with the operation of the driver. In general, applications must avoid resetting the printer or causing the page to be printed.

It is strongly recommended that applications do not perform actions that consume printer memory, such as downloading a font or a macro.

An application can avoid corrupting its data stream when issuing multiple, consecutive PASSTHROUGH escapes by not accessing the printer any other way during the sequence.

An application can guarantee that the PASSTHROUGH escape will be successful if it uses a "save" PostScript operator before sending PASSTHROUGH data and a "restore" operator after. Avoiding graphics device interface (GDI) functions between calls to the PASSTHROUGH escape and avoiding commands that cause a page to eject are other means to ensure that the escape will be successful.

The following is a sample Visual Basic program illustrating the use of this technique:

Option Explicit
 
Const PASSTHROUGH = 19
Const PCLmacro = "&f"
Const PCLOverlay = "y4X"
 
Declare Function Escape Lib "gdi" (ByVal hdc As Integer, ByVal Esc As Integer, ByVal ncount As Integer, ByVal InData As String, ByVal outdata As Any) As Integer
 
Sub Form_Load ()
    list1.AddItem ("Form 100")
    list1.AddItem ("Form 101")
End Sub
 
Sub List1_Click ()
 
    Dim PCL_Escape As String
    Dim Result As Integer
 
    Select Case list1.ListIndex
        Case 0
            PCL_Escape = Chr(27) & PCLMacro & "100" & PCLOverlay
        Case 1
            PCL_Escape = Chr(27) & PCLMacro & "101" & PCLOverlay
End Select
 
    PCL_Escape = Chr(Len(PCL_Escape) Mod 265) & Chr(Len(PCL_Escape) \ 265) & PCL_Escape
 
    printer.Print ""
 
    Result = Escape(printer.hdc, PASSTHROUGH, 0, PCL_Escape, 0&)
 
    Select Case Result
        Case Is < 0
            MsgBox "The PassThrough Escape is not supported by this printer driver.", 0 + 48 + 0
        Case 0
            MsgBox "An error occured sending the Escape Sequence.", 0 + 48 + 0
        Case Is > 0
            MsgBox "Escape successfully sent. Sending test printout to the printer.", 0 + 48 + 0
            printer.Print "Test case of "; list1.text
            printer.EndDoc
    End Select
 
End Sub

Comments:


file: /Techref/language/pcl/escwinapi.htm, 4KB, , updated: 2008/4/25 09:12, local time: 2024/12/27 22:16,
TOP NEW HELP FIND: 
18.217.26.8:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/Techref/language/pcl/escwinapi.htm"> Printing form images from printer-resident form storage in a programming language (e.g. Visual Basic.)</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .