Printing Landscape

' Use GetPrinterOrientation and SetPrinterOrientation(mOrientation) where
mOrientation = "Portrait" or "Landscape"
' unfortuately the code works only with Windows 95

Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Const PRINTER_ACCESS_ADMINISTER = &H4
Public Const DM_ORIENTATION = &H1&
Public Const DM_PAPERSIZE = &H2&
Public Const DM_PAPERLENGTH = &H4&
Public Const DM_PAPERWIDTH = &H8&
Public Const DM_SCALE = &H10&
Public Const DM_COPIES = &H100&
Public Const DM_DEFAULTSOURCE = &H200&
Public Const DM_PRINTQUALITY = &H400&
Public Const DM_COLOR = &H800&
Public Const DM_DUPLEX = &H1000&
Public Const DM_YRESOLUTION = &H2000&
Public Const DM_TTOPTION = &H4000&
Public Const DMORIENT_PORTRAIT = 1
Public Const DMORIENT_LANDSCAPE = 2
Public Const DM_UPDATE = 1
Public Const DM_COPY = 2
Public Const DM_PROMPT = 4
Public Const DM_MODIFY = 8
Public Const DM_IN_BUFFER = 8
Public Const DM_IN_PROMPT = 4
Public Const DM_OUT_BUFFER = 2
Public Const DM_OUT_DEFAULT = 1
Public Const HWND_BROADCAST = &HFFFF&
Public Const WM_DEVMODECHANGE = &H1B
Public Const WM_WININICHANGE = &H1A
Public Const DMPAPER_LETTER = 1 'Letter 8 1/2 x 11 in
Public Const DMPAPER_LEGAL = 5 ' Legal 8 1/2 x 14 in
Public Const DMPAPER_A4 = 9 ' A4 210 x 297 mm

Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
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
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type

Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As Long
DesiredAccess As Long
End Type

Declare Function DocumentProperties Lib "winspool.drv" Alias
"DocumentPropertiesA" _
(Byval hwnd As Long, Byval hPrinter As Long, Byval pDeviceName As String,
pDevModeOutput As DEVMODE, _
pDevModeInput As DEVMODE, Byval fMode As Long) As Long

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

Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (Byval
pPrinterName As String, phPrinter As Long, _
pDefault As PRINTER_DEFAULTS) As Long

Declare Function ClosePrinter Lib "winspool.drv" (Byval hPrinter As Long) As
Long

Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(Byval hwnd As Long, _
Byval wMsg As Long, _
Byval wParam As Long, _
lParam As Long) As Long

Function OpenDefaultPrinter(DeviceName) As Long
Dim hPrinter&
Dim pdefs As PRINTER_DEFAULTS

pdefs.pDatatype = ""
pdefs.pDevMode = 0
pdefs.DesiredAccess = PRINTER_ACCESS_ADMINISTER
dev = GetDefPrinter()
If dev = "" Then Exit Function
devname = GetDeviceName(dev)
devoutput = GetDeviceOutput(dev)
DeviceName = devname
res = OpenPrinter(devname, hPrinter, pdefs)
If res <> 0 Then
OpenDefaultPrinter = hPrinter
End If

End Function


Function GetDeviceName(dev)
npos = Instr(dev, ",")
GetDeviceName = Left(dev, npos - 1)

End Function

Function GetDeviceOutput(dev)
firstpos = Instr(dev, ",")
nextpos = Instr(firstpos + 1, dev, ",")
GetDeviceOutput = Mid(dev, nextpos + 1)

End Function
Function GetDefPrinter
def$ = String(128, 0)
di = GetProfileString("WINDOWS", "DEVICE", "", def$, 127)
GetDefPrinter = Trim(def$)

End Function
Function GetPrinterOrientation
' NOTE: This function returns what you would see if you clicked Start, Printer
Settings, and clicked properties for th
This was first published in November 2000

Dig deeper on Domino Resources - Part 4

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close