VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Dialogs

David Goben  (1 Submission)   Windows API Call/Explanation   Visual Basic 3.0   Beginner   Wed 3rd February 2021

This is one of over a hundred modules I have developed for getting my work done faster. This module display various system dialog boxes to configure COM ports, printer ports, get the default printer, view printer properties, and view document properties.

Assumes
This module should be saved as a .BAS file. I called it modPrinter.bas, but that was when it was a piece of baby code.

API Declarations
'*************************************************
' API calls, constants, and types
'*************************************************
' size of a device name string
Private Const CCHDEVICENAME = 32
' size of a form name string
Private Const CCHFORMNAME = 32
Private Const DM_IN_PROMPT = 4
Private Const DM_OUT_BUFFER = 2
Public Type DEVMODE
dmDeviceName As String * CCHDEVICENAME 'name of the printer
dmSpecVersion As Integer 'DEVMODE version
dmDriverVersion As Integer 'printer driver version
dmSize As Integer 'total size of DEVMODE w/o private data
dmDriverExtra As Integer 'total size of private data
dmFields As Long 'flags indicating which fields are valid
dmOrientation As Integer 'portraint/landscape (see DMORIENT_xxx)
dmPaperSize As Integer 'papersize (see DMPAPER_xxx)
dmPaperLength As Integer 'paper length in tenths of mm's
dmPaperWidth As Integer 'paper width in tenths of mm's
dmScale As Integer 'scales paper size by x/100
dmCopies As Integer 'number of copies
dmDefaultSource As Integer 'reserved. keep at zero
dmPrintQuality As Integer 'qualiyt (see DMRES_xxx) (or horz res DPI)
dmColor As Integer 'color type (see DMCOLOR_xx)
dmDuplex As Integer 'reserved
dmYResolution As Integer 'if not 0, vert res in DPI
dmTTOption As Integer 'How to print TT fonts (see DTT_xxx)
dmCollate As Integer 'collation (see DMCOLLATE_xxx)
dmFormName As String * CCHFORMNAME 'NT only. Name of printer form to use
dmUnusedPadding As Integer 'reserved
dmBitsPerPel As Integer 'bits per pixel for display (not printers)
dmPelsWidth As Long 'width of display in pixels (not printers)
dmPelsHeight As Long 'height of display in pixels (not printers)
dmDisplayFlags As Long 'DM_GRAYSCALE or SM_INTERLACED *not printers)
dmDisplayFrequency As Long 'Display frequency (not printers)
dmICMMethod As Long 'one of the DMICM_xxx constants (color matching)
dmICMIntent As Long 'one of the DMICM_xxx constants (intensity)
dmMediaType As Long 'one of the DMMEDIA_xxx constants
dmDitherType As Long 'on of the DMDITHER_xxx constants
dmReserved1 As Long 'reserved
dmReserved2 As Long 'reserved
End Type
Private Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As Long
DesiredAccess As Long
End Type
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8
Public Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function PrinterProperties Lib "winspool.drv" (ByVal hWnd As Long, ByVal hPrinter As Long) As Long
Private Declare Function AdvancedDocumentProperties Lib "winspool.drv" Alias "AdvancedDocumentPropertiesA" (ByVal hWnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, pDevModeOutput As DEVMODE, ByVal pDevModeInput As Long) As Long
Private Declare Function ConnectToPrinterDlg Lib "winspool.drv" (ByVal hWnd As Long, ByVal Flags As Long) As Long
Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hWnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As Long, ByVal pDevModeInput As Long, ByVal fMode As Long) As Long
Declare Function ConfigurePort Lib "winspool.drv" Alias "ConfigurePortA" (ByVal pName As String, ByVal hWnd As Long, ByVal pPortName As String) As Long
'customized calls
Private Declare Function DocumentPropertiesStr Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hWnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As String, ByVal pDevModeInput As String, ByVal fMode As Long) As Long
Private Declare Sub CopyMemoryDM Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As DEVMODE, ByVal source As String, ByVal Length As Long)

Rate Dialogs (3(3 Vote))
Dialogs.bas

Dialogs Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters