Stellen Sie die folgenden Deklarationen und Funktion in ein Modul. In einer Form platzieren Sie eine Listbox.
Option Explicit
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Global Const driverversion = 0 ' Device driver version
Global Const technology = 2 ' Device classification
Global Const DT_PLOTTER = 0 ' Vector plotter
Global Const DT_RASDISPLAY = 1 ' Raster display
Global Const DT_RASPRINTER = 2 ' Raster printer
Global Const DT_RASCAMERA = 3 ' Raster camera
Global Const DT_CHARSTREAM = 4 ' Character-stream, PLP
Global Const DT_METAFILE = 5 ' Metafile, VDM
Global Const DT_DISPFILE = 6 ' Display-file
Global Const horzsize = 4 ' Horizontal size in millimeters
Global Const vertsize = 6 ' Vertical size in millimeters
Global Const horzres = 8 ' Horizontal width in pixels
Global Const vertres = 10 ' Vertical width in pixels
Global Const BITSPIXEL = 12 ' Number of bits per pixel
Global Const PLANES = 14 ' Number of planes
Global Const Numbrushes = 16 ' Number of brushes the device has
Global Const numpens = 18 ' Number of pens the device has
Global Const nummarkers = 20 ' Number of markers the device has
Global Const numfonts = 22 ' Number of fonts the device has
Global Const numcolors = 24 ' Number of colors the device supports
Global Const PDEVICESIZE = 26 ' Size required for device descriptor
Global Const CURVECAPS = 28 ' Curve capabilities
Global Const LINECAPS = 30 ' Line capabilities
Global Const POLYGONALCAPS = 32 ' Polygonal capabilities
Global Const TEXTCAPS = 34 ' Text capabilities
Global Const CLIPCAPS = 36 ' Clipping capabilities
Global Const RASTERCAPS = 38 ' Bitblt capabilities
Global Const ASPECTX = 40 ' Length of the X leg
Global Const ASPECTY = 42 ' Length of the Y leg
Global Const ASPECTXY = 44 ' Length of the hypotenuse
Global Const logpixelsx = 88 ' Logical pixels/inch in X
Global Const logpixelsy = 90 ' Logical pixels/inch in Y
Global Const SIZEPALETTE = 104 ' Number of entries in physical palette
Global Const NUMRESERVED = 106 ' Number of reserved entries in palette
Global Const COLORRES = 108 ' Actual color resolution
Sub listefüllen()
Dim dc&, i%, s$
dc = Printer.hdc
Form1.List1.Clear
Form1.List1.AddItem "Treiberversion" & Chr(9) & CStr(GetDeviceCaps(dc, driverversion))
s = Choose(GetDeviceCaps(dc, technology) + 1, "Plotter", "Rasterbildschirm", _
"Rasterdrucker", "?", "Zeichendrucker", "Metafile", "?")
Form1.List1.AddItem "Technologie" & Chr(9) & s
Form1.List1.AddItem "Breite (mm)" & Chr(9) & CStr(GetDeviceCaps(dc, horzsize))
Form1.List1.AddItem "Höhe (mm)" & Chr(9) & CStr(GetDeviceCaps(dc, vertsize))
Form1.List1.AddItem "Breite (Pixel)" & Chr(9) & CStr(GetDeviceCaps(dc, horzres))
Form1.List1.AddItem "Höhe (Pixel)" & Chr(9) & CStr(GetDeviceCaps(dc, vertres))
Form1.List1.AddItem "DPI horiz " & Chr(9) & CStr(GetDeviceCaps(dc, logpixelsx))
Form1.List1.AddItem "DPI vert " & Chr(9) & CStr(GetDeviceCaps(dc, logpixelsy))
Form1.List1.AddItem "Seitenformat " & Chr(9) & Choose(Printer.Orientation, "Hochformat", "Queryformat")
Form1.List1.AddItem "Pinsel " & Chr(9) & CStr(GetDeviceCaps(dc, Numbrushes))
Form1.List1.AddItem "Stifte " & Chr(9) & CStr(GetDeviceCaps(dc, numpens))
Form1.List1.AddItem "Markierer " & Chr(9) & CStr(GetDeviceCaps(dc, nummarkers))
Form1.List1.AddItem "Schriften " & Chr(9) & Printer.FontCount
Form1.List1.AddItem "Farben " & Chr(9) & CStr(GetDeviceCaps(dc, numcolors))
Form1.List1.AddItem "CurrentX " & Chr(9) & Printer.CurrentX
Form1.List1.AddItem "CurrentY " & Chr(9) & Printer.CurrentY
Form1.List1.AddItem "DrawMode " & Chr(9) & Printer.DrawMode
Form1.List1.AddItem "DrawStyle " & Chr(9) & Printer.DrawStyle
Form1.List1.AddItem "DrawWidth " & Chr(9) & Printer.DrawWidth
Form1.List1.AddItem "FillColor " & Chr(9) & Printer.FillColor
Form1.List1.AddItem "FillStyle " & Chr(9) & Printer.FillStyle
Form1.List1.AddItem "FontBold " & Chr(9) & Printer.FontBold
Form1.List1.AddItem "FontItalic " & Chr(9) & Printer.FontItalic
Form1.List1.AddItem "FontSize " & Chr(9) & Printer.FontSize
Form1.List1.AddItem "FontStrikethru " & Chr(9) & Printer.FontStrikethru
Form1.List1.AddItem "FontTransparent " & Chr(9) & Printer.FontTransparent
Form1.List1.AddItem "FontUnderline " & Chr(9) & Printer.FontUnderline
Form1.List1.AddItem "ForeColor " & Chr(9) & Hex(Printer.ForeColor) + "H"
Form1.List1.AddItem "hDC " & Chr(9) & Printer.hdc
Form1.List1.AddItem "Height " & Chr(9) & Printer.Height
Form1.List1.AddItem "ScaleHeight " & Chr(9) & Printer.ScaleHeight
Form1.List1.AddItem "ScaleLeft " & Chr(9) & Printer.ScaleLeft
Form1.List1.AddItem "ScaleMode " & Chr(9) & Printer.ScaleMode
Form1.List1.AddItem "ScaleTop " & Chr(9) & Printer.ScaleTop
Form1.List1.AddItem "ScaleWidth " & Chr(9) & Printer.ScaleWidth
Form1.List1.AddItem "TwipsPerPixelX " & Chr(9) & Printer.TwipsPerPixelX
Form1.List1.AddItem "TwipsPerPixelY " & Chr(9) & Printer.TwipsPerPixelY
Form1.List1.AddItem "Width " & Chr(9) & Printer.Width
Form1.List1.AddItem "FontName: " & Chr(9) & Printer.FontName
End Sub