|
Option Explicit
Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal _
hDC As Long, ByVal nIndex As Long) As Long
Const PHYSICALOFFSETX As Long = 112
Const PHYSICALOFFSETY As Long = 113
Private Sub Form_Load()
Dim P As Integer
Dim I As Integer
For I = 0 To Printers.Count - 1
cboPrinter.AddItem Printers(I).DeviceName
If Printers(I).DeviceName = Printer.DeviceName Then
cboPrinter.ListIndex = I
End If
Next I
Druck_Raender
End Sub
Private Sub cboPrinter_Click()
Dim OldDeviceName As String
Dim P As Printer
OldDeviceName = Printer.DeviceName
For Each P In Printers
If P.DeviceName = cboPrinter.Text Then
Set Printer = P
End If
Next
fmeResult.Caption = "Druckränder beim " & Printer.DeviceName
Druck_Raender
For Each P In Printers
If P.DeviceName = OldDeviceName Then
Set Printer = P
End If
Next
End Sub
Sub Druck_Raender()
Dim BW As Long, BH As Long, BR As Long, BO As Long
Dim PSM As Long
BW = GetDeviceCaps(Printer.hDC, PHYSICALOFFSETX)
BH = GetDeviceCaps(Printer.hDC, PHYSICALOFFSETY)
PSM = Printer.ScaleMode
Printer.ScaleMode = 1
BO = Printer.ScaleY(BH, vbPixels, vbTwips)
BR = Printer.Height - BO - Printer.ScaleHeight
Label1(3).Caption = Format$(Printer.ScaleY(BR, vbTwips, _
vbMillimeters), "###.00") & " "
BO = Printer.ScaleX(BW, vbPixels, vbTwips)
BR = Printer.Width - BO - Printer.ScaleWidth
Label1(2).Caption = Format$(Printer.ScaleX(BR, vbTwips, _
vbMillimeters), "###.00") & " "
Printer.ScaleMode = PSM
Label1(0).Caption = Format$(Printer.ScaleX(BW, vbPixels, _
vbMillimeters), "###.00") & " "
Label1(1).Caption = Format$(Printer.ScaleY(BH, vbPixels, _
vbMillimeters), "###.00") & " "
Printer.KillDoc
End Sub
|
|