|
-
Jun 20th, 2002, 05:45 AM
#1
Thread Starter
New Member
VB Titlebar
Hi,
Is it possible to change the default font options and color options of the titlebar of a form? Is it possible at all?
-
Jun 20th, 2002, 06:25 AM
#2
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.
-
Jun 20th, 2002, 06:26 AM
#3
Addicted Member
How to draw your own titlebar?
Catholics Do It With Beads
-
Jun 20th, 2002, 06:28 AM
#4
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
-
Jun 20th, 2002, 06:29 AM
#5
Addicted Member
Thank you Mr. Hack...
Catholics Do It With Beads
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|