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
以下是引用tmtony在2005-9-30 0:02:00的发言:
作个补弃,我这里原来也整理了一贴,加了一些注释,不过,都来自KB:)
http://www.office-cn.net/Article/Class5/Class16/200411/556.html
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |