hilyete
Active Member
- Joined
- Aug 19, 2009
- Messages
- 293
I added some calls to the API to remove the close X from my userforms. I recently found this VB code to allow changing specified Window colors, but I haven't been able to turn it into "VBA" code acceptable to Excel. I wonder if someone can look at it and tell me what might need to be changed. It uses a userform with 2 control buttons. I get an error msg highlighting the "SetSysColors 19" in:
SetSysColors 19, IndexArray(0), SavedColors(0)
stating that a function or sub is expected.. ?
SetSysColors 19, IndexArray(0), SavedColors(0)
stating that a function or sub is expected.. ?
Code:
Declare Function GetSysColor Lib "User" (ByVal nIndex%) As Long
Declare Sub SetSysColors Lib "User" (ByVal nChanges%,lpSysColor%,lpColorValues&)
Declare Function GetSysColor Lib "User" (ByVal nIndex%) As Long
' Enter the following Declare statement as one, single line:
Declare Sub SetSysColors Lib "User" (ByVal nChanges%, lpSysColor%,lpColorValues&)
Const COLOR_BACKGROUND = 1
Const COLOR_ACTIVECAPTION = 2
Const COLOR_WINDOWFRAME = 6
Dim SavedColors(18) As Long
Sub Form_Load ()
' Save current system colors:
For i% = 0 To 18
SavedColors(i%) = GetSysColor(i%)
Next i%
End Sub
Sub Form1_Unload ()
' Restore system colors:
ReDim IndexArray(18) As Integer
For i% = 0 To 18
IndexArray(i%) = i%
Next i%
SetSysColors 19, IndexArray(0), SavedColors(0)
End Sub
Sub Command1_Click ()
' Change all display elements:
ReDim NewColors(18) As Long
ReDim IndexArray(18) As Integer
For i% = 0 to 18
NewColors(i%) = QBColor(Int(16 * Rnd))
IndexArray(i%) = i%
Next i%
SetSysColors 19, IndexArray(0), NewColors(0)
End Sub
Sub Command2_Click ()
' Change desktop, window frames, and active caption:
ReDim NewColors(18) As Long
ReDim IndexArray(18) As Integer
For i% = 0 to 18
NewColors(i%) = QBColor(Int(16 * Rnd))
IndexArray(i%) = i%
Next i%
SetSysColors 19, IndexArray(0), NewColors(0)
End Sub
Last edited: