|
Wie bekomme ich heraus, wieviele Twips ein Pixel hat?
Lösung:
Definiert ist, daß 1 Zoll 1440 Twips entsprechen. Wenn wir nun
herausbekommen können, wie viele Punkte das Ausgabegerät (Monitor
oder Drucker...) in einem Zoll darstellen kann (z.B. 600 DPI), dann könnte
man den Wert TwipsPerPixel einfach durch dividieren erhalten:
TwipsPerPixel = 1400 / (Pixel Pro Zoll)
Private Const LOGPIXELSX = 88 Private Const LOGPIXELSY = 90 Private Declare Function GetDesktopWindow& Lib "user32" () Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" _ (ByVal hDC As Long, ByVal nIndex As Long) As Long Private Declare Function ReleaseDC Lib "user32" _ (ByVal hwnd As Long, ByVal hDC As Long) As Long Public Function TwipsPerPixel(nIndex As Long) As Long Dim DesktopHWnd As Long ' Handle für den Desktop Dim hDC As Long ' Device Context Dim Dummy As Long ' ' Handle für Desktop ermitteln: ' DesktopHWnd = GetDesktopWindow() ' ' Device Context ermitteln: ' hDC = GetDC(DesktopHWnd) ' ' Twips pro Pixel errechnen: ' TwipsPerPixel = 1440 / GetDeviceCaps(hDC, nIndex) ' ' Device Context freigeben: ' Dummy = ReleaseDC(DesktophWnd, hDC) End Function
Debug.Print "Twips pro Pixel in X - Richtung: "; TwipsPerPixel (LOGPIXELSX) Debug.Print "Twips pro Pixel in Y - Richtung: "; TwipsPerPixel (LOGPIXELSY)
Tip 16: Bildschirmauflösung und Farbtiefe.
|
© 1999 T. Prötzsch |
Aktualisiert am 31. Mai 1999
|