home *** CD-ROM | disk | FTP | other *** search
- VBPRINT Library v2.00 written by Robert Simpson (Black Castle Software, LLC)
-
- This program has been released to the public domain. No warranties are
- expressed or implied. Use at your own risk.
-
- ---Overview---
- This DLL allows your Visual Basic applications to have better control over the
- printer device. It seems to be the one area MS has consistently forgotten in
- VB.
-
- By far the easiest method for changing printer orientation, paper settings,
- trays, color and etc is to use the DEVMODE structure and make calls to the
- printer driver's ExtDeviceMode() function. Unfortunately this particular
- function resides in the printer driver itself and VB cannot load that driver
- and call pointers to functions within it. Therefore, I have written a set of
- printer control functions which do exactly that. In addition, using the
- VBResetDC() function, you can make changes to the printer orientation and
- other settings during a print session (even if you're using VB's Printer
- object).
-
- One of the problems of course is that not all DEVMODE structures are created
- equal. Depending on the printer, the driver may append its own private data
- to the end of a DEVMODE structure, which further complicates the VB interface.
- The trick here is that all calls to VBPRINT use a special DEVMODE structure
- which I've modified for use with VB (hence called the VBDEVMODE). This
- VBDEVMODE allows the VB Programmer access to all the important items in the
- DEVMODE structure and still allows the printer to have its own private area.
-
-
- ---Features---
- Ability to get/set the Windows default printer
- Ability to list all the installed printers
- Allows VB to call the ExtDeviceMode() function of a printer
- Also allows VB to call the DeviceCapabilities() function of a printer
- Has special VB version of ResetDC() to change printer settings on the fly
- Uses a special DEVMODE structure specifically tailored for VB
- Can convert a VBDEVMODE structure from and to a VB String so it can be easily
- saved to disk and restored later
- What this means is, you now have an easy method for changing print orientation
- and any other printer settings through the use of the VBDEVMODE structure.
-
-
- ---Flavors of this Library (and why there ARE flavors!!)---
- This library comes in 3 flavors so just about any VB programmer can use it
-
- A VB3 version of the DLL (which is compatible with VB4/16-bit)
- A VB4/16-bit version (which is NOT compatible with VB3!!)
- A VB4/32-bit version (who's functions are identical to the VB4/16-bit version)
-
- Why is the VB3 version compatible with VB4 and the VB4 version not compatible
- with VB3? I decided that I wanted the VB4/32-bit and VB4/16-bit versions to
- be functionally identical, which meant that I had to allow for the fact that
- VB4/32-bit uses UNICODE strings (16-bits per character), and therefore I could
- not always write directly into memory because VB4 often does some unwanted
- translations when making function calls.
-
- The particular function affected (and the ONLY one affected) is the
- VBDeviceCapabilities() function. In the VB3 version, there is only ONE
- command, VBDeviceCapabilities(). Often this function returns an array of data
- to the user, which is no problem in VB3 or VB4/16-bit, you just pass the first
- dimension of the array (such as Names$(0) ) and the DLL can write all the
- elements of the array since they're stored linearly in memory.
- NOT SO in VB4/32-bit!! If you pass Names$(0) to a DLL, VB4 translates it from
- UNICODE to ANSI and gives you a new pointer to JUST THAT DIMENSION, leaving me
- no place to put the rest of the items that are supposed to go in the array.
-
- Therefore in order to make your VB code portable from 16-bits to 32-bits,
- the VB4 versions of the DLL have a VBDeviceCapArray() function, which is
- just an Alias to "VBDeviceCapabilities" but one that explicitly requires an
- array variable, which you would pass as Names$() (with NO numbers between the
- parens!).
-
- So if you are porting a VB3 program to use the NEW VB4 VBPRNTxx library, you
- will need to replace commands such as:
-
- i = VBDeviceCapabilities(DefPrinter$,DC_PAPERNAMES,Names$(0),inDEV)
-
- to the new format for arrays in the VB4 version:
-
- i = VBDeviceCapArray(DefPrinter$,DC_PAPERNAMES,Names$(),inDEV)
-
- **THIS IS THE ONLY DIFFERENCE IN FUNCTION CALLS**
-
-
- ---Using this DLL with the Printer Object---
- Most printing in VB goes through the Printer object, which leaves much to be
- desired. Normally in the Windows API you can pass a DEVMODE structure when
- you create a device context, which makes life much easier--you can include all
- your custom printer settings in the device open sequence and not have to
- bother with a bunch of subsequent Escape() functions.
- The VB Printer object doesn't allow this convenience. Therefore if you must
- use the VB Printer object, you have two options:
- (Assuming you've already got a VBDEVMODE structure filled in with your desired
- settings)
- #1
- Use the Printer object's .hDC property and call VBResetDC() with the filled-
- in VBDEVMODE structure. This is the easiest method...or...
-
- #2
- Call VBExtDeviceMode() and get the printer's current settings (see the
- functions reference for instructions on doing this)
-
- Make another call to VBExtDeviceMode() with your DEVMODE structure and tell
- the printer to use these settings as the new default settings.
-
- Use the Printer object to your heart's content
-
- When finished, one more call to VBExtDeviceMode() with the old default
- settings, restoring them back to the original.
-
- Using the utilities in this DLL, you'll be able to change printers, use them
- in ways you were unable to do previously, and change back to the default
- printer all without an annoying dialog box or having to prompt the user.
-
-
- ---The DEVMODE structure---
- If you're familiar with the DEVMODE structure, this one should look strikingly
- similar.
-
- Type DEVMODE_TYPE
- dmDeviceName As String * 32 ' VB4/32 uses an array of Byte
- dmSpecVersion As Integer
- dmDriverVersion As Integer
- dmSize As Integer
- dmDriverExtra As Integer
- dmFields As Long
- dmOrientation As Integer
- dmPaperSize As Integer
- dmPaperLength As Integer
- dmPaperWidth As Integer
- dmScale As Integer
- dmCopies As Integer
- dmDefaultSource As Integer
- dmPrintQuality As Integer
- dmColor As Integer
- dmDuplex As Integer
- dmYResolution As Integer
- dmTTOption As Integer
- dmPrivate As String
- End Type
-
- The 32-bit version adds several items to the above structure, and uses arrays
- of Byte instead of fixed-length strings because of the fact that strings are
- stored internally in UNICODE format (which means they're twice as large)
-
-
- The following is an exerpt from the Win3.1 SDK describing the elements of the
- DEVMODE structure:
-
- dmDeviceName
- Specifies the name of the device the driver supports--for example, "PCL/HP
- LaserJet" in the case of the Hewlett-Packard LaserJet. Each driver has a
- unique string.
-
- dmSpecVersion
- Specifies the version number of the DEVMODE structure. For Windows version
- 3.1, this value should be 0x30A.
-
- dmDriverVersion
- Specifies the printer driver version number assigned by the printer driver
- developer.
-
- dmSize
- Specifies the size, in bytes, of the DEVMODE structure. (This value does not
- include the optional dmDriverData member for device-specific data, which can
- follow the structure.) If an application manipulates only the driver-
- independent portion of the data, it can use this member to find out the length
- of the structure without having to account for different versions.
-
- dmDriverExtra
- Specifies the size, in bytes, of the optional dmDriverData member for device-
- specific data, which can follow the structure. If an application does not use
- device-specific information, it should set this member to zero.
-
- dmFields
- Specifies a set of flags that indicate which of the remaining members in the
- DEVMODE structure have been initialized. It can be any combination (or it can
- be none) of the following values:
-
- Constant Value
-
- DM_ORIENTATION 0x0000001L
- DM_PAPERSIZE 0x0000002L
- DM_PAPERLENGTH 0x0000004L
- DM_PAPERWIDTH 0x0000008L
- DM_SCALE 0x0000010L
- DM_COPIES 0x0000100L
- DM_DEFAULTSOURCE 0x0000200L
- DM_PRINTQUALITY 0x0000400L
- DM_COLOR 0x0000800L
- DM_DUPLEX 0x0001000L
- DM_YRESOLUTION 0x0002000L
- DM_TTOPTION 0x0004000L
-
- A printer driver supports only those members that are appropriate for the
- printer technology.
-
- dmOrientation
- Specifies the orientation of the paper. It can be either DMORIENT_PORTRAIT or
- DMORIENT_LANDSCAPE.
-
- dmPaperSize
- Specifies the size of the paper to print on. This member may be set to zero if
- the length and width of the paper are specified by the dmPaperLength and
- dmPaperWidth members, respectively. Otherwise, the dmPaperSize member can be
- set to one of the following predefined values:
-
- Value Meaning
-
- DMPAPER_FIRST DMPAPER_LETTER
- DMPAPER_LETTER Letter, 8 1/2 x 11 in.
- DMPAPER_LETTERSMALL Letter Small, 8 1/2 x 11 in.
- DMPAPER_TABLOID Tabloid, 11 x 17 in.
- DMPAPER_LEDGER Ledger, 17 x 11 in.
- DMPAPER_LEGAL Legal, 8 1/2 x 14 in.
- DMPAPER_STATEMENT Statement, 5 1/2 x 8 1/2 in.
- DMPAPER_EXECUTIVE Executive, 7 1/2 x 10 1/2 in.
- DMPAPER_A3 A3, 297 x 420 mm
- DMPAPER_A4 A4, 210 x 297 mm
- DMPAPER_A4SMALL A4 Small, 210 x 297 mm
- DMPAPER_A5 A5, 148 x 210 mm
- DMPAPER_B4 B4, 250 x 354 mm
- DMPAPER_B5 B5, 182 x 257 mm
- DMPAPER_FOLIO Folio, 8 1/2 x 13 in.
- DMPAPER_QUARTO Quarto, 215 x 275 mm
-
- DMPAPER_10X14 10 x 14 in.
- DMPAPER_11X17 11 x 17 in.
- DMPAPER_NOTE Note, 8 1/2 x 11 in.
- DMPAPER_ENV_9 Envelope #9, 3 7/8 x 8 7/8 in.
- DMPAPER_ENV_10 Envelope #10, 4 1/8 x 9 1/2 in.
- DMPAPER_ENV_11 Envelope #11, 4 1/2 x 10 3/8 in.
- DMPAPER_ENV_12 Envelope #12, 4 1/2 x 11 in.
- DMPAPER_ENV_14 Envelope #14, 5 x 11 1/2 in.
- DMPAPER_CSHEET C size sheet
- DMPAPER_DSHEET D size sheet
- DMPAPER_ESHEET E size sheet
- DMPAPER_ENV_DL Envelope DL, 110 x 220 mm
- DMPAPER_ENV_C3 Envelope C3, 324 x 458 mm
- DMPAPER_ENV_C4 Envelope C4, 229 x 324 mm
- DMPAPER_ENV_C5 Envelope C5, 162 x 229 mm
-
- DMPAPER_ENV_C6 Envelope C6, 114 x 162 mm
- DMPAPER_ENV_C65 Envelope C65, 114 x 229 mm
- DMPAPER_ENV_B4 Envelope B4, 250 x 353 mm
- DMPAPER_ENV_B5 Envelope B5, 176 x 250 mm
- DMPAPER_ENV_B6 Envelope B6, 176 x 125 mm
- DMPAPER_ENV_ITALY Envelope, 110 x 230 mm
- DMPAPER_ENV_MONARCH Envelope Monarch, 3 7/8 x 7 1/2 in.
- DMPAPER_ENV_PERSONAL Envelope, 3 5/8 x 6 1/2 in.
- DMPAPER_FANFOLD_US U.S. Standard Fanfold, 14 7/8 x 11 in.
- DMPAPER_FANFOLD_STD_GERMAN German Standard Fanfold, 8 1/2 x 12 in.
- DMPAPER_FANFOLD_LGL_GERMAN German Legal Fanfold, 8 1/2 x 13 in.
-
- DMPAPER_LAST German Legal Fanfold, 8 1/2 x 13 in.
- DMPAPER_USER User-defined
-
- dmPaperLength
- Specifies a paper length, in tenths of a millimeter. This parameter overrides
- the paper length specified by the dmPaperSize member, either for custom paper
- sizes or for such devices as dot-matrix printers that can print on a variety
- of page sizes.
-
- dmPaperWidth
- Specifies a paper width, in tenths of a millimeter. This parameter overrides
- the paper width specified by the dmPaperSize member.
-
- dmScale
- Specifies the factor by which the printed output is to be scaled. The
- apparent page size is scaled from the physical page size by a factor of
- dmScale/100. For example, a letter-size paper with a dmScale value of 50 would
- contain as much data as a page of size 17 by 22 inches because the output text
- and graphics would be half their original height and width.
-
- dmCopies
- Specifies the number of copies printed if the device supports multiple-page
- copies.
-
- dmDefaultSource
- Specifies the default bin from which the paper is fed. The application can
- override this value by using the GETSETPAPERBINS escape. This member can be
- one of the following values:
-
- DMBIN_AUTO DMBIN_LOWER
- DMBIN_CASSETTE DMBIN_MANUAL
- DMBIN_ENVELOPE DMBIN_MIDDLE
- DMBIN_ENVMANUAL DMBIN_ONLYONE
- DMBIN_FIRST DMBIN_SMALLFMT
- DMBIN_LARGECAPACITY DMBIN_TRACTOR
- DMBIN_LARGEFMT DMBIN_UPPER
- DMBIN_LAST
-
- A range of values is reserved for device-specific bins. To be consistent with
- initialization information, the GETSETPAPERBINS and ENUMPAPERBINS escapes use
- these values.
-
- dmPrintQuality
- Specifies the printer resolution. Following are the four predefined device-
- independent values:
-
- DMRES_HIGH (-4)
- DMRES_MEDIUM (-3)
- DMRES_LOW (-2)
- DMRES_DRAFT (-1)
-
- If a positive value is given, it specifies the number of dots per inch (DPI)
- and is therefore device-dependent. If the printer initializes the
- dmYResolution member, the dmPrintQuality member specifies the x-resolution
- of the printer, in dots per inch.
-
- dmColor
- Specifies whether a color printer is to render color or monochrome output.
- Possible values are:
-
- DMCOLOR_COLOR (1)
- DMCOLOR_MONOCHROME (2)
-
- dmDuplex
- Specifies duplex (double-sided) printing for printers capable of duplex
- printing. This member can be one of the following values:
-
- DMDUP_SIMPLEX (1)
- DMDUP_HORIZONTAL (2)
- DMDUP_VERTICAL (3)
-
- dmYResolution
- Specifies the y-resolution of the printer, in dots per inch. If the printer
- initializes this member, the dmPrintQuality member specifies the x-resolution
- of the printer, in dots per inch.
-
- dmTTOption
- Specifies how TrueType fonts should be printed. It can be one of the following
- values:
-
- Value Meaning
-
- DMTT_BITMAP Print TrueType fonts as graphics. This is the default action
- for dot-matrix printers.
-
- DMTT_DOWNLOAD Download TrueType fonts as soft fonts. This is the default
- action for Hewlett-Packard printers that use Printer Control Language (PCL).
-
- DMTT_SUBDEV Substitute device fonts for TrueType fonts. This is the
- default action for PostScript printers.
-
-
- -----------------------------------------------------------------------------
- -----------------------------------------------------------------------------
- -----------------------------------------------------------------------------
-
-
- VBPRINT Library Function Reference:
-
-
- ---General Notes---
- The VBDeviceCapabilities() function call is different in the VB3 version of
- the DLL. While VB4.0/16-bit is fully compatible with it and your VB3 apps
- will port flawlessly to VB4/16-bit, you will have to make some modifications
- to your code if you want to port it to VB4/32-bit.
-
- However, if you are writing in native VB4 and not coming from VB3, DO NOT USE
- VBPRINT.DLL IF YOU DON'T HAVE TO! Use the VB4 versions instead so that your
- 16-bit and 32-bit VB programs will be fully compatible.
-
-
- ---Functions---
-
- Declare:
- Declare Function VBGetPrinters() As String
-
- Example Usage:
- NextPrinter$ = VBGetPrinters()
-
- Description:
- This function works similar to the Dir$() VB function. Each time you call
- VBGetPrinters() it returns the next printer installed on the computer. It
- will return a NULL string when it has reached the end of the list.
-
- Returns:
- String
- The format for printers returned with this function (and the format for all
- functions requiring a printername) is:
- <printername> on <port>
-
- Example:
- Epson Stylus Pro on LPT1:
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBGetDefPrinter() As String
-
- Example Usage:
- DefPrinter$ = VBGetDefPrinter()
-
- Returns:
- String
- This function returns the Windows default printer in the same format as the
- VBGetPrinters() function above.
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBSetDefPrinter(DefPrinter As String) As Integer
-
- Example Usage:
- i = VBSetDefPrinter(DefPrinter$)
-
- Description:
- This function sets a new Windows Default printer.
-
- Returns:
- Integer
- 0 = (False) Unable to determine the printer's driver (typically printer not
- installed)
- -1 = (True) Success
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBGetDriverFromName Lib "vbprint.dll" (printername As String)
- As String
-
- Example Usage:
- Driver$ = VBGetDriverFromName(DefPrinter$)
-
- Description:
- This function returns the driver associated with a printer. This is the
- actual .DRV file that handles the printer. It's of little use other than for
- reference purposes only.
-
- Returns:
- String
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBDevModeToStr Lib "vbprint.dll" (inDev As DEVMODE_TYPE) As
- String
-
- Example Usage:
- Devmode$ = VBDevModeToStr(dmINPUT)
-
- Description:
- This function converts a VBDEVMODE structure to a string so that it can be
- easily saved to disk and/or restored later.
-
- Returns
- String
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBStrToDevMode Lib "vbprint.dll" (dmString As String, outDev
- As DEVMODE_TYPE) As Integer
-
- Example Usage:
- i = VBStrToDevMode(Devmode$,dmOUTPUT)
-
- Description:
- This function takes a string created with VBDevModeToStr() and dumps it into
- the specified VBDEVMODE structure, thereby restoring it back so you can once
- again easily edit it.
-
- Returns:
- Integer
- True = Success
- False = Fail (of course)
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBExtDeviceMode Lib "vbprint.dll" (ByVal hWnd As Integer,
- printername As String, inDev As DEVMODE_TYPE, outDev As DEVMODE_TYPE, ByVal
- fMode As Integer) As Integer
-
- Inputs:
- hWnd The parent window if you wish to open the printer's setup
- dialog. Can be 0 otherwise.
- printername The name and port of the printer to configure (formatted the
- same as all the other functions that refer to printers)
- inDev Input VBDEVMODE the printer driver should use. It can get its
- settings from here.
- outDev Output VBDEVMODE. The printer will return its current/default
- settings here.
- fMode Flags that tell the printer driver what to do with the data
- you just sent. Flags are as follows (any combo can be used)
-
- DM_IN_BUFFER Instructs the driver to get its new settings
- from the supplied inDev VBDEVMODE
- DM_OUT_BUFFER Tells the driver to dump its current settings
- into the supplied outDev VBDEVMODE
- DM_IN_PROMPT Brings up the printer's own settings dialog
- and allows the user to manually change things
- DM_OUT_DEFAULT All changes to the printer's settings are to
- be written out as the new Windows defaults for
- that printer
-
- Description:
- This is the one you've been waiting for. This function calls the printer's
- ExtDeviceMode() function, allowing you to give the printer new settings, get
- its current settings, or update the Windows default settings.
-
- Notes:
- Do not use the same VBDEVMODE for input as you do for output. The results may
- be unreliable at best.
-
- Examples:
- i = VBExtDeviceMode(Me.hWnd,DefPrinter$,dmINPUT,dmOUTPUT,DM_OUT_BUFFER)
-
- ' Gets the printer's current settings and puts them in dmOUTPUT
-
- i = VBExtDeviceMode(Me.hWnd,DefPrinter$,dmINPUT,dmOUTPUT,DM_IN_BUFFER Or
- DM_OUT_DEFAULT)
-
- ' Tells the printer to use the settings in dmINPUT and to make them the new
- ' default settings for the printer
-
- i = VBExtDeviceMode(Me.hWnd,DefPrinter$,dmINPUT,dmOUTPUT,DM_IN_BUFFER Or
- DM_IN_PROMPT Or DM_OUT_BUFFER)
-
- ' Tells the printer driver to bring up its custom dialog using the settings
- ' supplied in dmINPUT. Allows the user to change anything, and the final
- ' settings will be placed in dmOUTPUT
-
- Returns:
- Integer
- This function returns whatever the ExtDeviceMode() returns. Usually IDOK or
- IDCANCEL if using the printer's dialog box. Otherwise it will usually
- return 1 for success. It can return the size of the DEVMODE structure if no
- flags are specified in the original function call. There are two more
- returns:
-
- False = Unable to open the printer driver
- True = Unable to determine the size of the DEVMODE structure
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBDeviceCapabilities Lib "vbprint.dll" (printername As
- String, Cap As Integer, lpszOutput As Any, inDev As DEVMODE_TYPE) As Long
-
- --and (VB4 versions only)--
-
- Declare Function VBDeviceCapArray Lib "vbprntxx.dll" Alias
- "VBDeviceCapabilities" (printername As String, Cap As Integer, lpszOutput() As
- Any, inDev As DEVMODE_TYPE) As Long
-
- Inputs:
- printername The name and port of the printer to query (formatted the
- same as all the other functions that refer to printers)
- Cap The particular capability you wish to query. Cap can be one
- of the following (taken directly from the Win3.1 SDK)
-
- Value Meaning
-
- DC_BINNAMES Copies an array containing a list of the names of the paper
- bins. This array is in the form char PaperNames[cBinMax]
- [cchBinName] where cchBinName is 24. If the lpszOutput
- parameter is NULL, the return value is the number of bin
- entries required. Otherwise, the return value is the number
- of bins copied.
-
- DC_BINS Retrieves a list of available bins. The function copies the
- list to the lpszOutput parameter as a WORD array. If
- lpszOutput is NULL, the function returns the number of
- supported bins to allow the application the opportunity to
- allocate a buffer with the correct size. For more information
- about these bins, see the description of the dmDefaultSource
- member of the DEVMODE structure.
-
- DC_COPIES Returns the number of copies the device can print.
-
- DC_DRIVER Returns the version number of the printer driver.
-
- DC_DUPLEX Returns the level of duplex support. The function returns 1 if
- the printer is capable of duplex printing. Otherwise, the
- return value is zero.
-
- DC_ENUMRESOLUTIONS Returns a list of available resolutions. If lpszOutput
- is NULL, the function returns the number of available
- resolution configurations. Resolutions are represented by
- pairs of LONG integers representing the horizontal and
- vertical resolutions (specified in dots per inch).
- DC_EXTRA Returns the number of bytes required for the device-specific
- portion of the DEVMODE structure for the printer driver.
-
- DC_FIELDS Returns the dmFields member of the printer driver's DEVMODE
- structure. The dmFields member indicates which fields in the
- device-independent portion of the structure are supported by
- the printer driver.
-
- DC_FILEDEPENDENCIES Returns a list of files that also need to be loaded
- when a driver is installed. If the lpszOutput parameter is
- NULL, the function returns the number of files. Otherwise,
- lpszOutput points to an array of filenames in the form
- char[chFileName, 64]. Each filename is a null-terminated
- string.
-
- DC_MAXEXTENT Returns a POINT structure containing the maximum paper size
- that the dmPaperLength and dmPaperWidth members of the printer
- driver's DEVMODE structure can specify.
-
- DC_MINEXTENT Returns a POINT structure containing the minimum paper size
- that the dmPaperLength and dmPaperWidth members of the printer
- driver's DEVMODE structure can specify.
-
- DC_ORIENTATION Returns the relationship between portrait and landscape
- orientations for a device, in terms of the number of degrees
- that portrait orientation is rotated counterclockwise to
- produce landscape orientation. The return value can be one of
- the following:
-
- Value Meaning
-
- 0 No landscape orientation.
- 90 Portrait is rotated 90 degrees to produce landscape.
- (For example, Hewlett-Packard PCL printers.)
- 270 Portrait is rotated 270 degrees to produce landscape.
- (For example, dot-matrix printers.)
-
- DC_PAPERNAMES Retrieves a list of supported paper names--for example, Letter
- or Legal. If the lpszOutput parameter is NULL, the function
- returns the number of paper sizes available. Otherwise,
- lpszOutput points to an array for the paper names in the form
- char[cPaperNames, 64]. Each paper name is a null-terminated
- string.
-
- DC_PAPERS Retrieves a list of supported paper sizes. The function copies
- the list to lpszOutput as a WORD array and returns the number
- of entries in the array. If lpszOutput is NULL, the function
- returns the number of supported paper sizes to allow the
- application the opportunity to allocate a buffer with the
- correct size. For more information on paper sizes, see the
- description of the dmPaperSize member of the DEVMODE structure.
-
- DC_PAPERSIZE Copies the dimensions of all supported paper sizes, in tenths
- of a millimeter, to an array of POINT structures pointed to by
- the lpszOutput parameter. The width (x-dimension) and length
- (y-dimension) of a paper size are returned as if the paper
- were in the DMORIENT_PORTRAIT orientation.
-
- DC_SIZE Returns the dmSize member of the printer driver's DEVMODE
- structure.
-
- DC_TRUETYPE Retrieves the abilities of the driver to use TrueType fonts.
- The return value can be one or more of the following:
-
- Value Meaning
-
- DCTT_BITMAP Device is capable of printing TrueType fonts
- as graphics. (For example, dot-matrix and PCL
- printers.)
- DCTT_DOWNLOAD Device is capable of downloading TrueType
- fonts. (For example, PCL and PostScript
- printers.)
- DCTT_SUBDEV Device is capable of substituting device fonts
- for TrueType fonts. (For example, PostScript
- printers.)
-
- For DC_TRUETYPE, the lpszOutput parameter should be NULL.
-
- DC_VERSION Returns the specification version to which the printer driver
- conforms.
-
-
-
- lpszOutput Usually an array of some type or another (depending on the
- capability you are querying). See notes below on how to
- properly pass an array here.
- InDev A VBDEVMODE structure. The printer driver can get its info
- either from this structure (if filled in) or will get its
- info from the default settings if you do not fill it in.
-
- Description:
- This function calls the DeviceCapabilities() printer driver function to query
- the printer on a particular feature that it may have. This can be used to
- obtain the list of available paper types, get info on paper bins and even the
- types of print resolutions (DPI) available.
-
- Notes:
- When querying the device on a parameter that returns an array of data, you
- should first query it with a 0 lpszOutput parameter. Example:
-
- l = VBDeviceCapabilities(DefPrinter$, DC_PAPERNAMES, ByVal 0&, inDev)
-
- This will return the number of papernames the device uses. The "ByVal 0&" is
- very important. DO NOT USE NULL OR FORGET THE "&"!! The input param will
- be expecting a Long, so don't give it anything else.
- Once you've DIMmed an array to hold the data, you can then call it again with
- the destination array:
-
- (VB3 library version)
- l = VBDeviceCapabilities(DefPrinter$, DC_PAPERNAMES, Names$(0), inDev)
-
- (VB4 16/32 bit library version)
- l = VBDeviceCapArray(DefPrinter$, DC_PAPERNAMES, Names$(), inDev)
-
- For the VB3 version of this function, always reference the first element in
- the array in the function call (in this case, Name$(0) since 0 is typically
- the first element in any array).
-
- For VB4, do not mention ANY element in the array, just pass the whole array.
-
- The VB3 module VBPRINT.BAS (VBPRNT32.BAS for VB4) contains easy-to-use "Types"
- (structures) that will make it easier for you to call the queries that return
- arrays. In the VBPRINT.FRM (VBPRNT32.FRM for VB4) file, the Sub ShowOptions
- gives several practical examples of making this call using the Type's from
- the .BAS file.
-
- Returns:
- Long
- False = Failure
- Anything else is success.
- -----------------------------------------------------------------------------
-
- Declare:
- Declare Function VBResetDC(ByVal hDC As Integer, outDev As DEVMODE_TYPE) As
- Integer
-
- Inputs:
- hDC The device context to reset
- outDev A new DEVMODE structure containing any new settings to give
- the opened device
-
- Description:
- The VBResetDC function updates the given device context, based on the
- information in the specified DEVMODE structure. Among other things, this
- command can be used to change the paper orientation or paper bins during a
- print session.
-
- Returns:
- Integer
- The return value is the handle of the original device context if the function
- is successful. Otherwise, it is False.
- -----------------------------------------------------------------------------
-
-
- Robert Simpson
- Programmer at Large
- BC Software
- Phx, AZ
- simpson@primenet.com
-