Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21193

How to detect windows font size in VB6

$
0
0
I have VB6 code which detect windows font size(DPI) like following.

Code:

Public Function GetFontSizeDPI() As Long
  Dim hwnd As Long
  Dim hdc As Long
  Dim logPix As Long
  Dim SmallFonts As Boolean
  Dim LOGPIXELSX As Long

  hwnd = GetDesktopWindow
  hdc = GetDC(hwnd)

  LOGPIXELSX = 88
  logPix = GetDeviceCaps(hdc, LOGPIXELSX)
  Call ReleaseDC(hwnd, hdc)

  GetFontSizeDPI = logPix
End Function

This code returns correctly in Windows XP.
(Small=96/Large=120)

But returns wrong result in Windows 7.
(Small=96/Medium=120/Large=96)

How do I get correct font DPI value in Windows 7?

Viewing all articles
Browse latest Browse all 21193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>