Click here to Skip to main content
15,563,228 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have created a VB.net project which looks great in win7 but its awful in winXP, my requirement is to change the color of the title bar of the application- i know that it depend on the Windows theme you select, still i m looking for an option. I m new to .net , please help
Posted

1 solution

Here is some code:


VB
Option Explicit
Private Const COLOR_ACTIVECAPTION = 2
Private Declare Function GetSysColor Lib _
  "user32" (ByVal nIndex As Long) As Long
Private Declare Function SetSysColors Lib "user32" _
  (ByVal nChanges As Long, lpSysColor As Long, _
   lpColorValues As Long) As Long




VB
Public Function GetTitleBarColor() As Long
    GetTitleBarColor = GetSysColor(COLOR_ACTIVECAPTION)
End Function
Public Function ChangeTitleBarColor(NewColor As Long) As Boolean
    Dim lRet As Long
    lRet = SetSysColors(1, COLOR_ACTIVECAPTION, NewColor)
    ChangeTitleBarColor = lRet > 0
End Function


Hope that helps
 
Share this answer
 
Comments
souvikd 29-Jul-10 4:21am    
Hi Dalek, thanks for replying .... i m trying your code while loading the form, but its not working, its showing me the default old xp title bar,please chk the code to understand better


Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim s As Long = GetTitleBarColor()
ChangeTitleBarColor(s)

Dim frmCCS As New frmCrtConStr
frmCCS.ShowDialog()

Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Public Function GetTitleBarColor() As Long
GetTitleBarColor = GetSysColor(COLOR_ACTIVECAPTION)
End Function

Public Function ChangeTitleBarColor(ByVal NewColor As Long) As Boolean
Dim lRet As Long
lRet = SetSysColors(1, COLOR_ACTIVECAPTION, NewColor)
ChangeTitleBarColor = lRet > 0
End Function

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900