When dealing with laptops, some apps will display incorrectly depending upon the font size of the system...



VB Code:
  1. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  2. Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
  3.  
  4. Private Declare Function GetTextMetrics Lib "gdi32" Alias "GetTextMetricsA" (ByVal hdc As Long, lpMetrics As TEXTMETRIC) As Long
  5.  
  6. Private Declare Function SetMapMode Lib "gdi32" (ByVal hdc As Long, ByVal nMapMode As Long) As Long
  7.  
  8. Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
  9.  
  10. Private Const MM_TEXT = 1
  11.  
  12. Private Type TEXTMETRIC
  13.  
  14.    tmHeight As Integer
  15.    tmAscent As Integer
  16.    tmDescent As Integer
  17.    tmInternalLeading As Integer
  18.    tmExternalLeading As Integer
  19.    tmAveCharWidth As Integer
  20.    tmMaxCharWidth As Integer
  21.    tmWeight As Integer
  22.    tmItalic As String * 1
  23.    tmUnderlined As String * 1
  24.    tmStruckOut As String * 1
  25.    tmFirstChar As String * 1
  26.    tmLastChar As String * 1
  27.    tmDefaultChar As String * 1
  28.    tmBreakChar As String * 1
  29.    tmPitchAndFamily As String * 1
  30.    tmCharSet As String * 1
  31.    tmOverhang As Integer
  32.    tmDigitizedAspectX As Integer
  33.    tmDigitizedAspectY As Integer
  34.  
  35. End Type
  36.  
  37. '  Returns true if the system is using small fonts,
  38. '  false if using large fonts
  39. '
  40. '  Source: the MS knowlege base article Q152136.
  41. '
  42. Public Function SmallFonts() As Boolean
  43.  
  44.    Dim hdc As Long
  45.  
  46.    Dim hwnd As Long
  47.  
  48.    Dim PrevMapMode As Long
  49.  
  50.    Dim tm As TEXTMETRIC
  51.  
  52.    ' Set the default return value to small fonts
  53.    SmallFonts = True
  54.    
  55.    ' Get the handle of the desktop window
  56.    hwnd = GetDesktopWindow()
  57.  
  58.    ' Get the device context for the desktop
  59.    hdc = GetWindowDC(hwnd)
  60.  
  61.    If hdc Then
  62.  
  63.       ' Set the mapping mode to pixels
  64.       PrevMapMode = SetMapMode(hdc, MM_TEXT)
  65.      
  66.       ' Get the size of the system font
  67.       GetTextMetrics hdc, tm
  68.  
  69.       ' Set the mapping mode back to what it was
  70.       PrevMapMode = SetMapMode(hdc, PrevMapMode)
  71.  
  72.       ' Release the device context
  73.       ReleaseDC hwnd, hdc
  74.      
  75.       ' If the system font is more than 16 pixels high,
  76.       ' then large fonts are being used
  77.       If tm.tmHeight > 16 Then SmallFonts = False
  78.  
  79.    End If
  80.  
  81. End Function