System Fonts

Category: Fonts

Date: 02-16-2022

Return to Index


 
'Credit: Pierre Bellisle
 
'Compilable Example:  (Jose Includes)
 
'Get Windows default font, was "MS Sans Serif", 8 before Windows 7 and "Segoe UI", 9 since then.
 
#Compile Exe '#Win 8.04#
#Register None
#Dim All
#Include "Win32Api.Inc"
 
'______________________________________________________________________________
 
Function PBMain()
 Local ncMetric       As NONCLIENTMETRICS
 Local hDC            As Dword
 Local LogicalPixelsY As Long
 
 hDC = GetDC(%HWND_Desktop)
 LogicalPixelsY = GetDeviceCaps(hDC, %LOGPIXELSY)
 ReleaseDC(%HWND_Desktop, hDC)
 
 ncMetric.cbSize = SizeOf(NONCLIENTMETRICS)
 SystemParametersInfo(%SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), ncMetric, 0)
 
 MessageBox(%HWND_Desktop, _
 "Border width:"        & $Tab & Str$(ncMetric.iBorderWidth)               & $CrLf & _
 "Scroll width:"        & $Tab & Str$(ncMetric.iScrollWidth)               & $CrLf & _
 "Scroll height:"       & $Tab & Str$(ncMetric.iScrollHeight)              & $CrLf & _
 ""                                                                        & $CrLf & _
 "Caption font: "       & $Tab & ncMetric.lfCaptionFont.lfFaceName & ","   & _
 Str$(MulDiv(Abs(ncMetric.lfCaptionFont.lfHeight), 72, LogicalPixelsY))    & $CrLf & _ 'Convert to point size.
 "Caption width:"       & $Tab & Str$(ncMetric.iCaptionWidth)              & $CrLf & _
 "Caption height:"      & $Tab & Str$(ncMetric.iCaptionHeight)             & $CrLf & _
 ""                                                                        & $CrLf & _
 "Small caption font: " & $Tab & ncMetric.lfSmCaptionFont.lfFaceName & "," & _
 Str$(MulDiv(Abs(ncMetric.lfSmCaptionFont.lfHeight), 72, LogicalPixelsY))  & $CrLf & _ 'Convert to point size.
 "Small capt width:"    & $Tab & Str$(ncMetric.iSmCaptionWidth)            & $CrLf & _
 "Small capt height:"   & $Tab & Str$(ncMetric.iSmCaptionHeight)           & $CrLf & _
 ""                                                                        & $CrLf & _
 "Menu font: "          & $Tab & ncMetric.lfMenuFont.lfFaceName & ","      & _
 Str$(MulDiv(Abs(ncMetric.lfMenuFont.lfHeight), 72, LogicalPixelsY))       & $CrLf & _ 'Convert to point size.
 "Menu width:"          & $Tab & Str$(ncMetric.iMenuWidth)                 & $CrLf & _
 "Menu height:"         & $Tab & Str$(ncMetric.iMenuHeight)                & $CrLf & _
 ""                                                                        & $CrLf & _
 "Status font: "        & $Tab & ncMetric.lfStatusFont.lfFaceName & ","    & _
 Str$(MulDiv(Abs(ncMetric.lfStatusFont.lfHeight), 72, LogicalPixelsY))     & $CrLf & _ 'Convert to point size.
 ""                                                                        & $CrLf & _
 "Message font: "       & $Tab & ncMetric.lfMessageFont.lfFaceName & ","   & _
 Str$(MulDiv(Abs(ncMetric.lfMessageFont.lfHeight), 72, LogicalPixelsY)),     _         'Convert to point size.
 "SPI_GETNONCLIENTMETRICS", %MB_Ok)
 
End Function
 
'gbs_01281
'Date: 05-11-2013


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm