Try this:
'***
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function GetDesktopWindow _
Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
(ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Const LOGPIXELSX = 88 ' Logical pixels/inch in X
Private Const LOGPIXELSY = 90 ' Logical pixels/inch in Y
Private Const TwipsPerInch = 1440
Private Sub Form_Load()
Dim DeskWnd As Long, DeskDC As Long
DeskWnd = GetDesktopWindow()
DeskDC = GetDC(DeskWnd)
MsgBox (TwipsPerInch / GetDeviceCaps(DeskDC, LOGPIXELSX)) & _
" * " & (TwipsPerInch / GetDeviceCaps(DeskDC, LOGPIXELSY))
Call ReleaseDC(DeskWnd, DeskDC)
End Sub
'***
Hope this helps,
Mike
-- EDais --
- Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/
Work E-Mail: ED...@btclick.com
Other E-Mail: Mike....@btclick.com
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long,
ByVal nIndex As Long) As Long
Private Const DRIVERVERSION As Long = 0 'Device driver
version
Private Const TECHNOLOGY As Long = 2 'Device
classification
Private Const HORZSIZE As Long = 4 'Horizontal size in
millimeters
Private Const VERTSIZE As Long = 6 'Vertical size in
millimeters
Private Const HORZRES As Long = 8 'Horizontal width in
pixels
Private Const VERTRES As Long = 10 'Vertical height in
pixels
Private Const BITSPIXEL As Long = 12 'Number of bits per
pixel
Private Const PLANES As Long = 14 'Number of planes
Private Const NUMBRUSHES As Long = 16 'Number of brushes
the device has
Private Const NUMPENS As Long = 18 'Number of pens the
device has
Private Const NUMMARKERS As Long = 20 'Number of markers
the device has
Private Const NUMFONTS As Long = 22 'Number of fonts the
device has
Private Const NUMCOLORS As Long = 24 'Number of colors the
device supports
Private Const PDEVICESIZE As Long = 26 'Size required for
device descriptor
Private Const CURVECAPS As Long = 28 'Curve capabilities
Private Const LINECAPS As Long = 30 'Line capabilities
Private Const POLYGONALCAPS As Long = 32 'Polygonal
capabilities
Private Const TEXTCAPS As Long = 34 'Text capabilities
Private Const CLIPCAPS As Long = 36 'Clipping
capabilities
Private Const RASTERCAPS As Long = 38 'Bitblt capabilities
Private Const ASPECTX As Long = 40 'Length of the X leg
Private Const ASPECTY As Long = 42 'Length of the Y leg
Private Const ASPECTXY As Long = 44 'Length of the
hypotenuse
Private Const SHADEBLENDCAPS As Long = 45 'Shading and blending
caps (IE5)
Private Const LOGPIXELSX As Long = 88 'Logical pixels/inch
in X
Private Const LOGPIXELSY As Long = 90 'Logical pixels/inch
in Y
Private Const SIZEPALETTE As Long = 104 'Number of entries in
physical palette
Private Const NUMRESERVED As Long = 106 'Number of reserved
entries in palette
Private Const COLORRES As Long = 108 'Actual color
resolution
Private Const VREFRESH As Long = 116 'Current vertical
refresh rate of the
'display device (for
displays only) in Hz
Private Const DESKTOPVERTRES As Long = 117 'Horizontal width of
entire desktop in pixels (NT5)
Private Const DESKTOPHORZRES As Long = 118 'Vertical height of
entire desktop in pixels (NT5)
Private Const BLTALIGNMENT As Long = 119 'Preferred blt
alignment
Public Function GetCaps()
Dim A1 As Long
Dim A2 As Long
Dim A3 As Long
Dim A4 As Long
Dim A5 As Long
Dim A6 As Long
Dim A7 As Long
Dim A8 As Long
A1 = GetDeviceCaps(AForm.hdc, HORZSIZE) 'Horizontal size in
millimetres
A2 = GetDeviceCaps(AForm.hdc, VERTSIZE) 'Vertical size in
millimetres
A3 = GetDeviceCaps(AForm.hdc, HORZRES) 'Horizontal width in
pixels
A4 = GetDeviceCaps(AForm.hdc, VERTRES) 'Vertical height in
pixels
A5 = GetDeviceCaps(AForm.hdc, BITSPIXEL) 'Number of bits per
pixel
A6 = GetDeviceCaps(AForm.hdc, LOGPIXELSX) 'Logical pixels/inch
in X
A7 = GetDeviceCaps(AForm.hdc, LOGPIXELSY) 'Logical pixels/inch
in Y
A8 = GetDeviceCaps(AForm.hdc, BITSPIXEL)
GetCaps = Array(A1, A2, A3, A4, A5, A6, A7, A8)
End Function
Screen.TwipsPerPixelX
as part of a calculation to determine the exact
coordinate on the control being clicked to determine the index of that item.
MSAccess doesn't have such a property so I need an API that could give me
the
Screen.TwipsPerPixelX for the current computer?
--
George Padvorac
geo...@dontspamme-nwis.net