PDA

View Full Version : How to change title bar font in vb



stupid man
15-05-2003, 16:08
Mấy anh giỏi giỏi vb ơi, cho đệ hỏi cái, làm sao đổi được font cuả title bar và menu bar = vb, thay vì vào display setting\ appearance\advance\ rồi chọn font.

Nicky
15-05-2003, 19:37
Bạn có thể dùng API để làm.


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

Private Sub Combo1_Click()
Dim ncm As NONCLIENTMETRICS
Dim Orincm As NONCLIENTMETRICS
Dim Returned As Long
Dim i As Integer
ncm.cbSize = Len(ncm)
Returned = SystemParametersInfo(41, 0, ncm, 0)
Orincm = ncm
For i = 1 To Len(Combo1.Text)
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
ncm.lfCaptionFont.lfFaceName(i) = 0
Returned = SystemParametersInfo(42, 0, ncm, &H1 Or &H2)
MsgBox "Message & Caption Font Changed To " & Combo1.Text, vbOKOnly, "NILESH"
Returned = SystemParametersInfo(42, 0, Orincm, &H1 Or &H2)
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 30
Combo1.AddItem Screen.Fonts(i)
Next i
End Sub

stupid man
15-05-2003, 22:33
Oh, very cool, and it'll be more cool if only my form's titlebar's font change, not with orthers application.

White_Rose
16-05-2003, 02:30
Oh, very cool, and it'll be more cool if only my form's titlebar's font change, not with orthers application.In order to solve your request, you have to sub-class to re-draw title-bar, menu... with your font (use TextOut or TextOutW function).
By the way, i think you should use a "1 byte VN" font (example VietKey font) and change title-bar's system font :-)

dtt_vn
16-05-2003, 12:27
cái này dtt_vn mới viết, chưa test với những trường hợp bị lỗi, tuy nhiên, nó cũng được lắm

dtt_vn
16-05-2003, 12:31
cái này là gurhanbutton dùng kèm cho đẹp. nếu không muốn, bạn có thể load lên rồi save hình lại, sau đó bỏ cái ocx này đi

tranthevu
13-06-2021, 13:59
Xin up lại với ạ...kg download được
thanks