Results 1 to 5 of 5

Thread: Setting Printer Escape Sequences in Vb6

  1. #1
    Join Date
    Dec 2008
    Posts
    94

    idea Setting Printer Escape Sequences in Vb6

    Hello Friends,

    I would like to know that how do i set Printer Escape Sequences in Vb6. Does any body know how can i do so? Can any body provide me the correct logical solution for the above issue? Any help on the above issue would be apppreciated.

    Thanks.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Setting Printer Escape Sequences in Vb6

    The Windows API Escape() function is provided in Windows versions 3.0 and 3.1 for backward compatibility with earlier versions of Microsoft Windows. Applications are supposed to use the GDI DeviceCapabilities() and ExtDeviceMode() functions instead of the Escape() function, but neither DeviceCapabilities() nor ExtDeviceMode() can be called directly from Visual Basic. This is because they are exported by the printer driver, not by the Windows GDI. The only way to use ExtDeviceMode() or DeviceCapabilities() in Visual Basic is to create a DLL and call them from there.

    There have been reports of problems using the PASSTHROUGH escape with the driver HPPCL5A.DRV. This is the version of the printer driver for the HP LaserJet III series that shipped with Windows 3.1. A more recent version of the driver (HPPCL5MS.DRV), which has no known problems with the PASSTHROUGH escape, is available in the Windows Driver Library (WDL). To obtain the latest driver for the HP LaserJet III series, download the self-extracting file HPPCL5.EXE from the WDL.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Setting Printer Escape Sequences in Vb6

    You can try out in VB by the old Basic method.

    Code:
    Open "LPT1:" for output as #1
    Print #1, strWhatever
    Print #1, chrFormFeed
    Close #1

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Setting Printer Escape Sequences in Vb6

    This is usually done with printer escape codes. Two ways of doing this come to mind. First, if the formatting you want to do is not complex, you could figure out the escape codes to do the formatting you require, and write them to the device. Printer manuals used to come with listings of the escape codes. More recently you might have to look them up on the internet or reverse engineer them from files printed using the driver.

    The second way would be to build your own print spooler. Write your jobs to files instead of to the spooler. Then have your own program open the files, write the data to the printer, and leave out the page eject escape codes.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Setting Printer Escape Sequences in Vb6

    To work around this problem,PrintBinaryFile function, a full-featured version of some code I already used myself to print pre-formatted files to a HP Laserjet printer. An enhanced version of the function (PR2FILE.MAK).

    One of the very first things we need to do before using PrintBinaryFile is determining the operating system we’re running on. Windows NT and Windows 95 contain a very handy library called ‘WinSpool’ that helps us work around a minor problem that PrintBinaryFile has when running on Windows 3.1: the need for a (hardcoded) printer driver filename. PrintBinaryFile needs to call the ExtDeviceMode function, which is contained in the printer driver file, and as VB is needs to know the exact name of each library, you’ll need to hard-code this driver file name. This is not really a problem, as the output you’ll be generating is printer-dependent anyway, and you’ll be able to make assumptions about the driver without much problems. When running on Windows NT or Windows 95, we can use the ExtDeviceMode function in the WinSpool driver, which on NT is called WinSpool.DRV and WinSpl16.DRV on Windows 95. Please note that I got reports of GPFs when using WinSpl16 on some builds of Windows 95: unless your testing shows it works OK, you might want to treat this version in the same way as Windows 3.1.

    The actual PrintBinaryFile function takes four parameters: Fil$, the fully qualified DOS filename of the file you want to print, DOSDevice$, the DOS device name (f.e. LPT1: or \SERVERPRINTER) for the printer device, DocName$, the description for the document that will show up in the Print Manager and DocFile$, in case you want to print to a file. The last parameter doesn’t make any real sense, as you will already have got a file if you want to use PrintBinaryFile, but it might be useful in other situations. PrintBinaryFile first looks up the DOS device you specify in WIN.INI (or the Registry emulation therof provided by NT) to find out the name of the printer driver. This driver is subsequently loaded into memory using the LoadLibrary API call.

Similar Threads

  1. Resident Evil The Mercenaries 3D: Death Sequences
    By Namkar in forum Video Games
    Replies: 7
    Last Post: 28-07-2011, 11:02 PM
  2. Replies: 2
    Last Post: 08-08-2009, 10:44 AM
  3. Setting Up Network Printer in Windows XP Operating System
    By Computer_Freak in forum Guides & Tutorials
    Replies: 6
    Last Post: 26-02-2009, 12:19 PM
  4. problem in merging two sequences in xslt
    By - Empty Shell - in forum Software Development
    Replies: 6
    Last Post: 25-10-2008, 05:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,721,302,442.87298 seconds with 17 queries