[2005] Using SetSysColor API
I want to change the frame color of all windows on a PC using the SetSysColor API. i implemeted the API as shown below but nothign happens. No errors but no color change either. I'm testing this on an XP machine.
vb Code:
Public Declare Function SetSysColors Lib "user32" _
(ByVal nChanges As Integer, _
ByVal lpSysColor As Integer, _
ByVal lpColorValues As Integer) As Boolean
Public Declare Function GetSysColor Lib "user32" _
(ByVal nIndex As Integer) As Integer
Private Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window
Private Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window
Private Const COLOR_CAPTIONTEXT = 9
Private OriginalActiveColor As Long ' Holds original active title bar color
Private OriginalInactiveColor As Long ' Holds original inactive title bar color
Public Sub InitColors()
OriginalActiveColor = GetSysColor(COLOR_ACTIVECAPTION)
OriginalInactiveColor = GetSysColor(COLOR_INACTIVECAPTION)
End Sub
Public Sub ResetColors() ' Resets the original system colors
SetSysColors(1, COLOR_ACTIVECAPTION, OriginalActiveColor)
SetSysColors(1, COLOR_INACTIVECAPTION, OriginalInactiveColor)
End Sub
Public Sub ChangeColors()
' Change active title bar color to black
SetSysColors(1, COLOR_ACTIVECAPTION, RGB(0, 0, 0))
' Change inactive title bar color to black
SetSysColors(1, COLOR_INACTIVECAPTION, RGB(0, 0, 0))
End Sub
Re: [2005] Using SetSysColor API
Perhaps this will help?
http://allapi.mentalis.org/apilist/SetSysColors.shtml
You may need to pass the args ByRef like shown in the code examples at the bottom of the linked page.
Re: [2005] Using SetSysColor API
Also
http://pinvoke.net is a good resource. They have more .net examples than allapi does.
Re: [2005] Using SetSysColor API
Old habbits die hard. I keep forgetting about pinvoke. :(
Re: [2005] Using SetSysColor API
;) Someday... someday lol
Re: [2005] Using SetSysColor API
Quote:
You may need to pass the args ByRef like shown in the code examples
You were right. I missed the fact that I was passing the arguments byVal versus byRef. I still can't get the window frame bar to change color. I had to fall back and simply change the color of the caption text.
Is there any reason that I can't change the window frame color? If I look in the dispaly properties, the frame color is set to red but all of my frames still appear as blue.