home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / vbprnt20.zip / VB4 / VBPRNT32.BAS < prev    next >
BASIC Source File  |  1996-05-31  |  11KB  |  238 lines

  1. Attribute VB_Name = "VBPRINT1"
  2. ' Examples for using the VBPRINT Library
  3. ' Written by Robert Simpson (Black Castle Software, LLC)
  4. ' Released to the public domain on 05/23/1996.
  5.  
  6. DefInt I
  7. DefLng L
  8. DefStr S
  9.  
  10. Option Explicit
  11.  
  12. ' Flags to use in the dmFields section of the VBDEVMODE
  13.  
  14. Global Const DM_IN_BUFFER = 8
  15. Global Const DM_IN_PROMPT = 4
  16. Global Const DM_OUT_BUFFER = 2
  17. Global Const DM_OUT_DEFAULT = 1
  18. Global Const DM_ORIENTATION = &H1
  19. Global Const DM_PAPERSIZE = &H2
  20. Global Const DM_PAPERLENGTH = &H4
  21. Global Const DM_PAPERWIDTH = &H8
  22. Global Const DM_SCALE = &H10
  23. Global Const DM_COPIES = &H100
  24. Global Const DM_DEFAULTSOURCE = &H200
  25. Global Const DM_PRINTQUALITY = &H400
  26. Global Const DM_COLOR = &H800
  27. Global Const DM_DUPLEX = &H1000
  28. Global Const DM_YRESOLUTION = &H2000
  29. Global Const DM_TTOPTION = &H4000
  30.  
  31. ' Here is the VB DEVMODE that should be used in all calls to this DLL requiring a DEVMODE structure:
  32.  
  33. Type DEVMODE_TYPE
  34.   dmDeviceName(31) As Byte
  35.   dmSpecVersion As Integer
  36.   dmDriverVersion As Integer
  37.   dmSize As Integer
  38.   dmDriverExtra As Integer
  39.   dmFields As Long
  40.   dmOrientation As Integer
  41.   dmPaperSize As Integer
  42.   dmPaperLength As Integer
  43.   dmPaperWidth As Integer
  44.   dmScale As Integer
  45.   dmCopies As Integer
  46.   dmDefaultSource As Integer
  47.   dmPrintQuality As Integer
  48.   dmColor As Integer
  49.   dmDuplex As Integer
  50.   dmYResolution As Integer
  51.   dmTTOption As Integer
  52. #If Win32 Then
  53.   dmCollate As Integer
  54.   dmFormName(31) As Byte
  55.   dmLogPixels As Integer
  56.   dmBitsPerPel As Long
  57.   dmPelsWidth As Long
  58.   dmPelsHeight As Long
  59.   dmDisplayFlags As Long
  60.   dmDisplayFrequency As Long
  61. #End If
  62.   dmPrivate As String
  63. End Type
  64.  
  65. '  The DEVMODE_TYPE structure in VB is essentially a base DEVMODE structure with a dynamic
  66. '  string attached to the end
  67.  
  68. Type BINNAMES_TYPE
  69.   sName As String * 24
  70. End Type
  71.  
  72. Type ENUMRESOLUTIONS_TYPE
  73.   xdpi As Long
  74.   ydpi As Long
  75. End Type
  76.  
  77. Type FILEDEPENDENCIES_TYPE
  78.   sFilename As String * 64
  79. End Type
  80.  
  81. Type PAPERNAMES_TYPE
  82.   sName As String * 64
  83. End Type
  84.  
  85. #If Win32 Then
  86. Type PAPERSIZE_TYPE
  87.   x As Long
  88.   y As Long
  89. End Type
  90.  
  91. Declare Function VBGetPrinters Lib "vbprnt32.dll" () As String
  92. Declare Function VBGetDriverFromName Lib "vbprnt32.dll" (printername As String) As String
  93. Declare Function VBSetDefPrinter Lib "vbprnt32.dll" (printername As String) As Integer
  94. Declare Function VBGetDefPrinter Lib "vbprnt32.dll" () As String
  95. Declare Function VBExtDeviceMode Lib "vbprnt32.dll" (ByVal hWnd As Integer, printername As String, inDev As DEVMODE_TYPE, outDEV As DEVMODE_TYPE, ByVal fMode As Integer) As Integer
  96. Declare Function VBDevModeToStr Lib "vbprnt32.dll" (inDev As DEVMODE_TYPE) As String
  97. Declare Function VBStrToDevMode Lib "vbprnt32.dll" (dmString As String, outDEV As DEVMODE_TYPE) As Integer
  98. Declare Function VBDeviceCapabilities Lib "vbprnt32.dll" (printername As String, ByVal iCap As Integer, lpVoid As Any, inDev As DEVMODE_TYPE) As Long
  99. Declare Function VBDeviceCapArray Lib "vbprnt32.dll" Alias "VBDeviceCapabilities" (printername As String, ByVal iCap As Integer, lpVoid() As Any, inDev As DEVMODE_TYPE) As Long
  100. Declare Function VBResetDC Lib "vbprnt32.dll" (ByVal hDC As Integer, outDEV As DEVMODE_TYPE) As Integer
  101.  
  102. #Else
  103. Type PAPERSIZE_TYPE
  104.   x As Integer
  105.   y As Integer
  106. End Type
  107.  
  108. Declare Function VBGetPrinters Lib "vbprnt16.dll" () As String
  109. Declare Function VBGetDriverFromName Lib "vbprnt16.dll" (printername As String) As String
  110. Declare Function VBSetDefPrinter Lib "vbprnt16.dll" (printername As String) As Integer
  111. Declare Function VBGetDefPrinter Lib "vbprnt16.dll" () As String
  112. Declare Function VBExtDeviceMode Lib "vbprnt16.dll" (ByVal hWnd As Integer, printername As String, inDev As DEVMODE_TYPE, outDEV As DEVMODE_TYPE, ByVal fMode As Integer) As Integer
  113. Declare Function VBDevModeToStr Lib "vbprnt16.dll" (inDev As DEVMODE_TYPE) As String
  114. Declare Function VBStrToDevMode Lib "vbprnt16.dll" (dmString As String, outDEV As DEVMODE_TYPE) As Integer
  115. Declare Function VBDeviceCapabilities Lib "vbprnt16.dll" (printername As String, ByVal iCap As Integer, lpVoid As Any, inDev As DEVMODE_TYPE) As Long
  116. Declare Function VBDeviceCapArray Lib "vbprnt16.dll" Alias "VBDeviceCapabilities" (printername As String, ByVal iCap As Integer, lpVoid() As Any, inDev As DEVMODE_TYPE) As Long
  117. Declare Function VBResetDC Lib "vbprnt16.dll" (ByVal hDC As Integer, outDEV As DEVMODE_TYPE) As Integer
  118. #End If
  119.  
  120. ' orientation selections
  121. Global Const DMORIENT_PORTRAIT = 1
  122. Global Const DMORIENT_LANDSCAPE = 2
  123.  
  124. ' paper selections
  125. '  Warning: The PostScript driver mistakingly uses DMPAPER_ values between
  126. ' *  50 and 56.  Don't use this range when defining new paper sizes.
  127.  
  128. Global Const DMPAPER_LETTER = 1               ' Letter 8 1/2 x 11 in
  129. Global Const DMPAPER_FIRST = DMPAPER_LETTER
  130. Global Const DMPAPER_LETTERSMALL = 2          ' Letter Small 8 1/2 x 11 in
  131. Global Const DMPAPER_TABLOID = 3              ' Tabloid 11 x 17 in
  132. Global Const DMPAPER_LEDGER = 4               ' Ledger 17 x 11 in
  133. Global Const DMPAPER_LEGAL = 5                ' Legal 8 1/2 x 14 in
  134. Global Const DMPAPER_STATEMENT = 6            ' Statement 5 1/2 x 8 1/2 in
  135. Global Const DMPAPER_EXECUTIVE = 7            ' Executive 7 1/4 x 10 1/2 in
  136. Global Const DMPAPER_A3 = 8                   ' A3 297 x 420 mm
  137. Global Const DMPAPER_A4 = 9                   ' A4 210 x 297 mm
  138. Global Const DMPAPER_A4SMALL = 10             ' A4 Small 210 x 297 mm
  139. Global Const DMPAPER_A5 = 11                  ' A5 148 x 210 mm
  140. Global Const DMPAPER_B4 = 12                  ' B4 250 x 354
  141. Global Const DMPAPER_B5 = 13                  ' B5 182 x 257 mm
  142. Global Const DMPAPER_FOLIO = 14               ' Folio 8 1/2 x 13 in
  143. Global Const DMPAPER_QUARTO = 15              ' Quarto 215 x 275 mm
  144. Global Const DMPAPER_10X14 = 16               ' 10x14 in
  145. Global Const DMPAPER_11X17 = 17               ' 11x17 in
  146. Global Const DMPAPER_NOTE = 18                ' Note 8 1/2 x 11 in
  147. Global Const DMPAPER_ENV_9 = 19               ' Envelope #9 3 7/8 x 8 7/8
  148. Global Const DMPAPER_ENV_10 = 20              ' Envelope #10 4 1/8 x 9 1/2
  149. Global Const DMPAPER_ENV_11 = 21              ' Envelope #11 4 1/2 x 10 3/8
  150. Global Const DMPAPER_ENV_12 = 22              ' Envelope #12 4 \276 x 11
  151. Global Const DMPAPER_ENV_14 = 23              ' Envelope #14 5 x 11 1/2
  152. Global Const DMPAPER_CSHEET = 24              ' C size sheet
  153. Global Const DMPAPER_DSHEET = 25              ' D size sheet
  154. Global Const DMPAPER_ESHEET = 26              ' E size sheet
  155. Global Const DMPAPER_ENV_DL = 27              ' Envelope DL 110 x 220mm
  156. Global Const DMPAPER_ENV_C5 = 28              ' Envelope C5 162 x 229 mm
  157. Global Const DMPAPER_ENV_C3 = 29              ' Envelope C3  324 x 458 mm
  158. Global Const DMPAPER_ENV_C4 = 30              ' Envelope C4  229 x 324 mm
  159. Global Const DMPAPER_ENV_C6 = 31              ' Envelope C6  114 x 162 mm
  160. Global Const DMPAPER_ENV_C65 = 32             ' Envelope C65 114 x 229 mm
  161. Global Const DMPAPER_ENV_B4 = 33              ' Envelope B4  250 x 353 mm
  162. Global Const DMPAPER_ENV_B5 = 34              ' Envelope B5  176 x 250 mm
  163. Global Const DMPAPER_ENV_B6 = 35              ' Envelope B6  176 x 125 mm
  164. Global Const DMPAPER_ENV_ITALY = 36           ' Envelope 110 x 230 mm
  165. Global Const DMPAPER_ENV_MONARCH = 37         ' Envelope Monarch 3.875 x 7.5 in
  166. Global Const DMPAPER_ENV_PERSONAL = 38        ' 6 3/4 Envelope 3 5/8 x 6 1/2 in
  167. Global Const DMPAPER_FANFOLD_US = 39          ' US Std Fanfold 14 7/8 x 11 in
  168. Global Const DMPAPER_FANFOLD_STD_GERMAN = 40  ' German Std Fanfold 8 1/2 x 12 in
  169. Global Const DMPAPER_FANFOLD_LGL_GERMAN = 41  ' German Legal Fanfold 8 1/2 x 13 in
  170. Global Const DMPAPER_LAST = DMPAPER_FANFOLD_LGL_GERMAN
  171. Global Const DMPAPER_USER = 256
  172.  
  173. ' bin selections
  174. Global Const DMBIN_UPPER = 1
  175. Global Const DMBIN_FIRST = DMBIN_UPPER
  176. Global Const DMBIN_ONLYONE = 1
  177. Global Const DMBIN_LOWER = 2
  178. Global Const DMBIN_MIDDLE = 3
  179. Global Const DMBIN_MANUAL = 4
  180. Global Const DMBIN_ENVELOPE = 5
  181. Global Const DMBIN_ENVMANUAL = 6
  182. Global Const DMBIN_AUTO = 7
  183. Global Const DMBIN_TRACTOR = 8
  184. Global Const DMBIN_SMALLFMT = 9
  185. Global Const DMBIN_LARGEFMT = 10
  186. Global Const DMBIN_LARGECAPACITY = 11
  187. Global Const DMBIN_CASSETTE = 14
  188. Global Const DMBIN_LAST = DMBIN_CASSETTE
  189. Global Const DMBIN_USER = 256             ' device specific bins start here
  190.  
  191. ' print qualities
  192. Global Const DMRES_DRAFT = -1
  193. Global Const DMRES_LOW = -2
  194. Global Const DMRES_MEDIUM = -3
  195. Global Const DMRES_HIGH = -4
  196.  
  197. ' color enable/disable for color printers
  198. Global Const DMCOLOR_MONOCHROME = 1
  199. Global Const DMCOLOR_COLOR = 2
  200.  
  201. ' duplex enable
  202. Global Const DMDUP_SIMPLEX = 1
  203. Global Const DMDUP_VERTICAL = 2
  204. Global Const DMDUP_HORIZONTAL = 3
  205.  
  206. ' TrueType options
  207. Global Const DMTT_BITMAP = 1          ' print TT fonts as graphics
  208. Global Const DMTT_DOWNLOAD = 2        ' download TT fonts as soft fonts
  209. Global Const DMTT_SUBDEV = 3          ' substitute device fonts for TT fonts
  210.  
  211. ' device capabilities indices
  212. Global Const DC_FIELDS = 1            ' Returns the dmFields member of the DEVMODE structure
  213. Global Const DC_PAPERS = 2            ' Reutrns an array of type Integer listing available paper sizes (see above DMPAPER consts)
  214. Global Const DC_PAPERSIZE = 3         ' Copys dims of all supported paper sizes (in 10ths of millimeters) to a PAPERSIZE_TYPE structure
  215. Global Const DC_MINEXTENT = 4         ' Returns a POINT_TYPE containing the min papersize that dmPaperLength and dmPaperWidth can specify
  216. Global Const DC_MAXEXTENT = 5         ' Returns a POINT_TYPE containing the max papersize that dmPaperLength and dmPaperWidth can specify
  217. Global Const DC_BINS = 6              ' Returns an array of type Integer containing the available paper bins for the printer (see above DMBIN consts)
  218. Global Const DC_DUPLEX = 7            ' Returns the level of duplex support
  219. Global Const DC_SIZE = 8              ' Returns the dmSize member of the DEVMODE structure
  220. Global Const DC_EXTRA = 9             ' Returns the # of bytes required for the driver-specific portion of the DEVMODE structure
  221. Global Const DC_VERSION = 10          ' Returns the spec version to which the printer driver conforms
  222. Global Const DC_DRIVER = 11           ' Returns the version # of the printer driver
  223. Global Const DC_BINNAMES = 12         ' Returns an array of BINNAMES_TYPE giving the names of the available paper bins
  224. Global Const DC_ENUMRESOLUTIONS = 13  ' Returns an array of ENUMRESOLUTIONS_TYPE showing the available DPI resolutions supported
  225. Global Const DC_FILEDEPENDENCIES = 14 ' Returns an array of FILEDEPENDENCIES_TYPE showing all the driver files needed for the printer
  226. Global Const DC_TRUETYPE = 15         ' Returns the level of ability the printer has for using TrueType fonts
  227. Global Const DC_PAPERNAMES = 16       ' Returns an array of PAPERNAMES_TYPE showing the names for the papers available
  228. Global Const DC_ORIENTATION = 17      ' Returns the relationship between portrait and landscape in terms of the number of degrees that portrait orientation is rotated counterclockwise to produce landscape orientation
  229. Global Const DC_COPIES = 18           ' Returns the # of copies the device can print
  230.  
  231. ' bit fields of the return value (DWORD) for DC_TRUETYPE
  232. Global Const DCTT_BITMAP = 1
  233. Global Const DCTT_DOWNLOAD = 2
  234. Global Const DCTT_SUBDEV = 4
  235.  
  236.  
  237.  
  238.