TwipsPerPixel Constant Question

J

Jack Leach

http://support.microsoft.com/kb/94927


Const LOGPIXELSX As Long = 88
Const LOGPIXELSY As Long = 90


Does anyone know what the purpose of these two constants are?




code...

Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
ByVal nIndex As Long) As Long

Const HWND_DESKTOP As Long = 0
Const LOGPIXELSX As Long = 88
Const LOGPIXELSY As Long = 90

'--------------------------------------------------
Function TwipsPerPixelX() As Single
'--------------------------------------------------
'Returns the width of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelX = 1440& / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC HWND_DESKTOP, lngDC
End Function

'--------------------------------------------------
Function TwipsPerPixelY() As Single
'--------------------------------------------------
'Returns the height of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelY = 1440& / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC HWND_DESKTOP, lngDC
End Function


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

John Spencer

As a guess that is the number of pixels per inch horizontally and vertically
at some specific screen resolution.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
V

vanderghast

That is right, but the returned value is not relly "reliable".

"Traditionally, video drivers report a value of 96 pixels per inch for small
fonts LOGPIXELSX and LOGPIXELSY values and 120 pixels per inch for large
fonts LOGPIXELSX and LOGPIXELSY values. However, this is not reliable
because there is no standard dictating these values. " ref:
http://support.microsoft.com/kb/177795


Vanderghast, Access MVP
 
J

Jack Leach

Thank you sir, you have jogged my memory


"LOGPIXELSX is the parameter you pass to GetDeviceCaps to get the current
monitor resolution (technically the horizontal resolution, but all modern
displays have equal horizontal and vertical resolution). Yes, it is always 88
- if you wanted to get a different value from GetDeviceCaps, you'd pass in a
different value. For example, to get the number of bits per pixel, you'd pass
the BITSPIXEL constant which is 12. These magic constants are defined in the
Windows API file WINGDI.h."

source:
http://stackoverflow.com/questions/...tandard-on-all-windows-pc-displays-logpixelsx
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top