|
-
Apr 5th, 2001, 08:11 PM
#1
Thread Starter
Addicted Member
I've been puzzling over this one for a day or so, I want to change the header bar of a window to black, but the only way I've been able to do this is to call the GetSysColor, SetSysColors. Now I want to restore the original colors whenever the user moves off the window. THe code I have catches it when you exit or minimize, but when you just click on another window it doesn't work.. Any suggestions?
Private Declare Function GetSysColor Lib "user32.dll" (ByVal nIndex As Long) As Long
Private Declare Function SetSysColors Lib "user32.dll" (ByVal cElements As Long, lpaElements As Long, lpaRgbValues As Long) As Long
Const COLOR_ACTIVECAPTION = 2
Const COLOR_GRADIENTACTIVECAPTION = 27
Const COLOR_GRADIENTINACTIVECAPTION = 28
Const COLOR_INACTIVECAPTION = 3
Dim colorNames(0 To 3) As Long ' identifiers of the system colors to change
Dim colorRGB(0 To 3) As Long ' RGB values of the system colors to change
Dim colorRGB2(0 To 3) As Long ' RGB values of the system colors to change
Dim retval As Long ' generic return value
Private Sub Form_Load()
CollectColors
End Sub
' Get the RGB values of the colors used in title bars.
Function CollectColors()
colorNames(0) = COLOR_ACTIVECAPTION
colorNames(1) = COLOR_GRADIENTACTIVECAPTION
colorNames(2) = COLOR_INACTIVECAPTION
colorNames(3) = COLOR_GRADIENTINACTIVECAPTION
colorRGB(0) = GetSysColor(COLOR_ACTIVECAPTION)
colorRGB(1) = GetSysColor(COLOR_GRADIENTACTIVECAPTION)
colorRGB(2) = GetSysColor(COLOR_INACTIVECAPTION)
colorRGB(3) = GetSysColor(COLOR_GRADIENTINACTIVECAPTION)
Dim state As Boolean
End Function
Private Sub Form_Resize()
If Me.WindowState = vbNormal Then
'Change colors to black
retval = SetSysColors(4, colorNames(0), colorRGB2(0))
state = True
ElseIf Me.WindowState = vbMinimized Then
'Change colors back
retval = SetSysColors(4, colorNames(0), colorRGB(0))
state = False
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'reset colors
retval = SetSysColors(4, colorNames(0), colorRGB(0))
End Sub
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
|