J
Jay
Hi -
WinXPProSP2/Office 2003: I'm programming in MS Access VBA and need to call a
WinAPI function. I'm new to coding API calls, so I don't yet understand the
conventions very well.
My specific goal is to determine the number of pixels per physical inch of
screen -both horizontally and vertically - for use elsewhere in my
application. From what I can tell, the 'getdevicecaps' function provides
pixels-per-inch (PPI), but I don't know how to implement it in VBA. So far,
I have the following code in a VBA module and would appreciate any advice on
how to code the function arguments (and anything else necessary to get this
to work properly):
Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Public Function GetHPixelsPerInch() As Long
'Get horizontal pixels per inch
pixH = GetDeviceCaps(<I don't know what goes here>)
GetHPixelsPerInch = pixH
End Function
Public Function GetVPixelsPerInch() As Long
'Get vertical pixels per inch
pixV = GetDeviceCaps(<I don't know what goes here>)
GetVPixelsPerInch = pixV
End Function
Sub screenPixPerInch()
MsgBox "X PPI = " & GetHPixelsPerInch & Chr(13) & _
"Y PPI = " & GetVPixelsPerInch
End Sub
WinXPProSP2/Office 2003: I'm programming in MS Access VBA and need to call a
WinAPI function. I'm new to coding API calls, so I don't yet understand the
conventions very well.
My specific goal is to determine the number of pixels per physical inch of
screen -both horizontally and vertically - for use elsewhere in my
application. From what I can tell, the 'getdevicecaps' function provides
pixels-per-inch (PPI), but I don't know how to implement it in VBA. So far,
I have the following code in a VBA module and would appreciate any advice on
how to code the function arguments (and anything else necessary to get this
to work properly):
Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Public Function GetHPixelsPerInch() As Long
'Get horizontal pixels per inch
pixH = GetDeviceCaps(<I don't know what goes here>)
GetHPixelsPerInch = pixH
End Function
Public Function GetVPixelsPerInch() As Long
'Get vertical pixels per inch
pixV = GetDeviceCaps(<I don't know what goes here>)
GetVPixelsPerInch = pixV
End Function
Sub screenPixPerInch()
MsgBox "X PPI = " & GetHPixelsPerInch & Chr(13) & _
"Y PPI = " & GetVPixelsPerInch
End Sub