Private Declare Function apiReleaseDC Lib "User32" _
Alias "ReleaseDC" _
(ByVal hwnd As Long, _
ByVal hDC As Long) _
As Long
Private Declare Function apiGetDeviceCaps Lib "Gdi32" _
Alias "GetDeviceCaps" _
(ByVal hDC As Long, _
ByVal nIndex As Long) _
As Long
Private Declare Function apiGetDC Lib "User32" _
Alias "GetDC" _
(ByVal hwnd As Long) _
As Long
Sub ConvertPIXELSToTWIPS(x As Long, Y As Long)
'From the KB
Dim hDC As Long, hwnd As Long, RetVal As Long
Dim XPIXELSPERINCH, YPIXELSPERINCH
Const LOGPIXELSX = 88
Const LOGPIXELSY = 90
hDC = apiGetDC(0)
XPIXELSPERINCH = apiGetDeviceCaps(hDC, LOGPIXELSX)
YPIXELSPERINCH = apiGetDeviceCaps(hDC, LOGPIXELSY)
RetVal = apiReleaseDC(0, hDC)
x = (x / XPIXELSPERINCH) * TWIPSPERINCH
Y = (Y / YPIXELSPERINCH) * TWIPSPERINCH
End Sub
[此贴子已经被作者于2005-9-29 21:07:08编辑过]
|