Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change Windows Forms Title Bar color
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00789220
Message ID:
00875675
Views:
24
Don,

Did you ever find another way to do this?

Kind Regards,

Mat

>Thanks, Cathy. You are always such a help on this forum. If I find a way to pull this off for a single window at a time I will let you know. But I am also doubtful...
>
>>Don,
>>
>>I'm sorry I wasn't more clear in my explanation. That is what I meant by changing the system colors. It will affect all your applications. Unfortunately, that is the only option you have tha I'm aware of.
>>
>>>Wow - I used the sample code you sent and it certainly worked, but all forms and applications take on the new colors (including MS Word and anything else I have open!)
>>>
>>>I'm writing a QuickBooks add-on, and trying to duplicate the Quickbooks layouts and colors. They use a system default for the main window, but use green for internal windows. But they have also managed to put help popups and other controls right in each Window title bar also. Maybe this was done using C++, but I would certainly love to duplicate this functionality of manipulating a form's title bar.
>>>
>>>Thank you for the code and effort! But in a commercial application the behaviour of changing all windows would be unacceptable.
>>>
>>>
>>>>Hi Don,
>>>>
>>>>There is not a easy way to set a the color of a single Window's title bar. You only can set the system color setting by via the SetSysColors API. You can work around the issue in this way:
>>>>
>>>>1. In the Activated event of the form store the Windows setting of the title bar and set it to your color
>>>>2. In the Deactivate event restore the Windows setting
>>>>
>>>>There is a sample code of it:
>>>>
>>>>
>>>>Imports System.Runtime.InteropServices
>>>>
>>>>
>>>>
>>>><DllImport("user32.dll")> _
>>>>Private Shared Function GetSysColor(ByVal nIndex As Int32) As Int32
>>>>End Function
>>>>
>>>><DllImport("user32.dll")> _
>>>>Private Shared Function SetSysColors(ByVal cElements As Integer, ByVal lpaElements() As Int32, ByVal lpaRgbValues() As Int32) As [Boolean]
>>>>End Function
>>>>
>>>>Private Const COLOR_ACTIVECAPTION As Integer = 2
>>>>
>>>>Private oldColor As Integer
>>>>
>>>>Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
>>>>    oldColor = GetSysColor(COLOR_ACTIVECAPTION)
>>>>
>>>>    Dim element() As Integer = {COLOR_ACTIVECAPTION}
>>>>    Dim rgb() As Integer = {Color.White.ToArgb() And &HFFFFFF}
>>>>    Dim b As Boolean = SetSysColors(1, element, rgb)
>>>>End Sub 'Form1_Activated
>>>>
>>>>Private Sub Form1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
>>>>    Dim element() As Integer = {COLOR_ACTIVECAPTION}
>>>>    Dim rgb() As Integer = {oldColor}
>>>>    Dim b As Boolean = SetSysColors(1, element, rgb)
>>>>End Sub 'Form1_Deactivate
>>>>
>>>>
>>>>>How do I change the color of the Title Bar in Windows Forms (VB.Net)? I need to set it to green and have been unable to find a reference so far.
Matthew Kennedy
Decision Support Technology Inc.

"I try to take one day at a time, but sometimes several days attack me all at once." ~ Ashleigh Brilliant

New Jersey Dot Net User Group
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform