Hi,
Is it possible to change the default font options and color options of the titlebar of a form? Is it possible at all?
Printable View
Hi,
Is it possible to change the default font options and color options of the titlebar of a form? Is it possible at all?
Not without changing the color scheme system wide, and the font property would apply to things printed directly to the form, not its caption property.
In order to accomplish what you ask, you would need to remove the existing titlebar, and programmatically draw your own.
How to draw your own titlebar? :confused:
Play around with this...VB Code:
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function DrawCaption Lib "User32" (ByVal hwnd As Long, ByVal hdc As Long, pcRect As RECT, ByVal un As Long) As Long Private Declare Function SetRect Lib "User32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Sub ReleaseCapture Lib "User32" () Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Private Const TitleWidth = 20 Private r As RECT Private Sub Form_Load() Form1.AutoRedraw = True Me.Cls Me.ScaleMode = vbPixels SetRect r, 0, 0, Me.ScaleWidth, TitleWidth 'To change the title bar color, replace '&H9' here and 'in the Form_Resize event with '&H18' or '&H19' or '&H28' or 'a value representing the color of your choice DrawCaption Me.hwnd, Me.hdc, r, &H9 End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Y > TitleWidth Then Exit Sub Dim lngReturnValue As Long If Button = 1 Then Call ReleaseCapture lngReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&) End If End Sub Private Sub Form_Resize() SetRect r, 0, 0, Me.ScaleWidth, TitleWidth DrawCaption Me.hwnd, Me.hdc, r, &H9 End Sub
Thank you Mr. Hack...:)