Hi,
Following code change the windows appearance through VB6 API. When your application run it change the fonts of windows appearence (all open windows). You can tweak it for more options such as color scheme, pictures and others.
In order to test the code open a project in VB6 then take a combo box on the form and paste the code in the form. Run & vola.
| Code: |
'<!--StartFragment-->'**************************************
'Windows API/Global Declarations for :Change System (Message, Menu, Caption) Fonts
'***********************************************************
Private Type LOGFONT
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(1 To 32) As Byte
End Type
Private Type NONCLIENTMETRICS
cbSize As Long
iBorderWidth As Long
iScrollWidth As Long
iScrollHeight As Long
iCaptionWidth As Long
iCaptionHeight As Long
lfCaptionFont As LOGFONT
iSMCaptionWidth As Long
iSMCaptionHeight As Long
lfSMCaptionFont As LOGFONT
iMenuWidth As Long
iMenuHeight As Long
lfMenuFont As LOGFONT
lfStatusFont As LOGFONT
lfMessageFont As LOGFONT
End Type
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As NONCLIENTMETRICS, ByVal fuWinIni As Long) As Long
'**************************************
' Inputs:ADD A COMBO BOX
'
' Returns:Changes the Message box font a
' nd Windows Caption Font (Title Font).
'
'Assumes:Add a Combo box.
'
'**************************************
Private Sub Combo1_Click()
Dim ncm As NONCLIENTMETRICS 'NONCLIENTMETRICS to change
Dim Orincm As NONCLIENTMETRICS 'NONCLIENTMETRICS to replace original
Dim Returned As Long
Dim i As Integer
ncm.cbSize = Len(ncm)
Returned = SystemParametersInfo(41, 0, ncm, 0) 'get the system NONCLIENTMETRICS
Orincm = ncm 'store the value of system NONCLIENTMETRICS to use later now to change the font name
'other functions can be used to change the font name
'but for simplicity i have used asc() mid()
For i = 1 To Len(Combo1.Text) 'use ncm.lfMenuFont.lfFacename(i) to change menu font
ncm.lfMessageFont.lfFaceName(i) = Asc(Mid(Combo1.Text, i, 1))
ncm.lfCaptionFont.lfFaceName(i) = Asc(Mid(Combo1.Text, i, 1))
Next i
ncm.lfMessageFont.lfFaceName(i) = 0 'add null at the end of font name
ncm.lfCaptionFont.lfFaceName(i) = 0
Returned = SystemParametersInfo(42, 0, ncm, &H1 Or &H2) 'remove &H2 if you don't want to affect all the open windows
MsgBox "Message & Caption Font Changed to " & Combo1.Text, vbOKOnly
Returned = SystemParametersInfo(42, 0, Orincm, &H1 Or &H2) 'replace original font
MsgBox "Message & Caption Font Replaced to " & StrConv(Orincm.lfCaptionFont.lfFaceName, vbUnicode), vbOKOnly, "NILESH"
End Sub
Private Sub Form_Load()
Dim i As Integer
Show
For i = 1 To 50 ' or use For i = 1 To Screen.FontCount to flood all the fonts in your pc
Combo1.AddItem Screen.Fonts(i)
Next i
End Sub |
Happy Hacking.
-DK
_________________
...we too are stardust...