Public Const LF_FACESIZE = 32
Public Type LOGFONT '60 byte
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Public Type NMLOGFONT '56 byte
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE - 4) As Byte
End Type
Public Type NONCLIENTMETRICS
cbSize As Long
iBorderWidth As Long
iScrollWidth As Long
iScrollHeight As Long
iCaptionWidth As Long
iCaptionHeight As Long
lfCaptionFont As NMLOGFONT
iSMCaptionWidth As Long
iSMCaptionHeight As Long
lfSMCaptionFont As NMLOGFONT
iMenuWidth As Long
iMenuHeight As Long
lfMenuFont As NMLOGFONT
lfStatusFont As NMLOGFONT
lfMessageFont As NMLOGFONT
End Type
Public Const REG_STRUCTURESIZE = 340 'Size of NONCLIENTMETRICS
Public Const SPI_SETNONCLIENTMETRICS = 42
Public Const SPI_GETNONCLIENTMETRICS = 41
Public Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Public newFontMetric As NONCLIENTMETRICS
Public oldFontMetric As NONCLIENTMETRICS
Public Sub ConvertFontToByte(ByRef lfFont As NMLOGFONT, ByRef fFontName As String)
Dim i As Byte
For i = 1 To Len(fFontName)
lfFont.lfFaceName(i - 1) = Asc(Mid(fFontName, i, 1))
Next
For i = Len(fFontName) To (LF_FACESIZE - 4)
lfFont.lfFaceName(i) = 0
Next
End Sub
Public Sub SetFont(ByVal newFontName As String)
newFontName = IIf(IsNull(newFontName), "VK Sans Serif", newFontName)
Dim VarGT As Long
oldFontMetric.cbSize = REG_STRUCTURESIZE
VarGT = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, REG_STRUCTURESIZE, oldFontMetric, 0)
newFontMetric.cbSize = REG_STRUCTURESIZE
newFontMetric.iCaptionWidth = 30
newFontMetric.lfCaptionFont.lfHeight = -13
newFontMetric.lfCaptionFont.lfWeight = 700
Call ConvertFontToByte(newFontMetric.lfCaptionFont, newFontName)
Call ConvertFontToByte(newFontMetric.lfMenuFont, newFontName)
Call ConvertFontToByte(newFontMetric.lfMessageFont, newFontName)
Call ConvertFontToByte(newFontMetric.lfSMCaptionFont, newFontName)
Call ConvertFontToByte(newFontMetric.lfStatusFont, newFontName)
VarGT = SystemParametersInfo(SPI_SETNONCLIENTMETRICS, REG_STRUCTURESIZE, newFontMetric, 0)
End Sub
Public Sub RestoreFont()
Dim VarGT As Long
oldFontMetric.cbSize = REG_STRUCTURESIZE
VarGT = SystemParametersInfo(SPI_SETNONCLIENTMETRICS, REG_STRUCTURESIZE, oldFontMetric, 0)
End Sub