offsetX = GetDeviceCaps(hPrinterDC, PHYSICALOFFSETX) 'in dots
offsetY = GetDeviceCaps(hPrinterDC, PHYSICALOFFSETY) 'in dots
Option Explicit
' Все значения возвращаются в пикселях!
'
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
' Constants for nIndex argument of GetDeviceCaps
Private Const HORZRES = 8
Private Const VERTRES = 10
Private Const LOGPIXELSX = 88
Private Const LOGPIXELSY = 90
Private Const PHYSICALWIDTH = 110
Private Const PHYSICALHEIGHT = 111
Private Const PHYSICALOFFSETX = 112
Private Const PHYSICALOFFSETY = 113
Public Property Get LeftMargin() As Integer
LeftMargin = GetDeviceCaps(Printer.hdc, PHYSICALOFFSETX)
End Property
Public Property Get TopMargin() As Integer
TopMargin = GetDeviceCaps(Printer.hdc, PHYSICALOFFSETY)
End Property
Public Property Get PhysWidth() As Integer
PhysWidth = GetDeviceCaps(Printer.hdc, PHYSICALWIDTH)
End Property
Public Property Get PhysHeight() As Integer
PhysHeight = GetDeviceCaps(Printer.hdc, PHYSICALHEIGHT)
End Property
Public Property Get PrintAreaHorz() As Integer
PrintAreaHorz = GetDeviceCaps(Printer.hdc, HORZRES)
End Property
Public Property Get PrintAreaVert() As Integer
PrintAreaVert = GetDeviceCaps(Printer.hdc, VERTRES)
End Property
Public Property Get RightMargin() As Integer
RightMargin = PhysWidth - PrintAreaHorz - LeftMargin
End Property
Public Property Get BottomMargin() As Integer
BottomMargin = PhysHeight - PrintAreaVert - TopMargin
End Property
Public Property Get dpiX() As Integer
dpiX = GetDeviceCaps(Printer.hdc, LOGPIXELSX)
End Property
Public Property Get dpiY() As Integer
dpiY = GetDeviceCaps(Printer.hdc, LOGPIXELSY)
End Property
offsetX_mm = 25.4 * GetDeviceCaps(hDC, PHYSICALOFFSETX) / GetDeviceCaps(hDC, LOGPIXELSX)
offsetY_mm = 25.4 * GetDeviceCaps(hDC, PHYSICALOFFSETY) / GetDeviceCaps(hDC, LOGPIXELSY)
Сейчас этот форум просматривают: SemrushBot и гости: 142