 |
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Form Title Bar Color
I think you would need to subclass the form and draw the title bar by yourself. But, I dont think it would be wise, since it can make user think that form is active, even if it isnt...
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
10-09-2004 at 08:17 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Form Title Bar Color
It came accross to me that it might be done with a little easier way. The idea is to always inform original window procedure to draw active title bar. There is a WM_NCACTIVATE message, which is sent to a window procedure whenever non-client area is activated/deactivated. If you look in documentation, you will see that wParam parameter holds the value that tells window procedure to draw active or inactive title bar.
wParam=False - inactive title bar
wParam=True ' active title bar
So, basically, if we intercept WM_NCACTIVATE and set wParam to 1, it should draw active title bar no matter if form is activated or deactivated. I assumed that you are familiar with subclassing, so I left the details abour DefWindowProc and how to subclass the window. I will post here module code that will show you how to intercept this message. To run this code, in Form_Load and Form_Unload events put
StartSubclassing Me.hWnd and
StopSubclassing Me.hWnd, respectively.
Code for module
Option Explicit
Const WM_NCACTIVATE = &H86
Const GWL_WNDPROC = (-4)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private PrevProc As Long
Public Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = WM_NCACTIVATE Then
wParam = 1
End If
WndProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
End Function
Public Sub StartSubclassing(ByVal hWnd As Long)
PrevProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WndProc)
End Sub
Public Sub StopSubclassing(ByVal hWnd As Long)
SetWindowLong hWnd, GWL_WNDPROC, PrevProc
End Sub |
This is only an idea, so it might need some extra coding, but I think it will give you a good start.
And one thing more, you could also set this main form as MDIForm, and other forms to child forms, so MDIForm title bar will always be active, no matter if you work on child forms.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
10-09-2004 at 11:59 PM |
|
|
|
|
 |
 |