VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "dwSysColor"
Attribute VB_Creatable = False
Attribute VB_Exposed = True
Option Explicit

' Class dwSysColor
' Desaware API Toolkit object library
' Copyright (c) 1996 by Desaware Inc.
' All rights reserved


#If Win32 Then
Private Declare Function apiGetSysColorBrush& Lib "user32" Alias "GetSysColorBrush" (ByVal nIndex As Long)
Private Declare Function apiGetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long
Private Declare Function apiSetSysColors Lib "user32" Alias "SetSysColors" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
#Else
Private Declare Function apiGetSysColor& Lib "user" Alias "GetSysColor" (ByVal nIndex%)
Private Declare Sub apiSetSysColors Lib "user" Alias "SetSysColors" (ByVal nChanges%, lpSysColor%, lpColorValues&)
#End If

Private Const COLOR_SCROLLBAR = 0
Private Const COLOR_BACKGROUND = 1
Private Const COLOR_ACTIVECAPTION = 2
Private Const COLOR_INACTIVECAPTION = 3
Private Const COLOR_MENU = 4
Private Const COLOR_WINDOW = 5
Private Const COLOR_WINDOWFRAME = 6
Private Const COLOR_MENUTEXT = 7
Private Const COLOR_WINDOWTEXT = 8
Private Const COLOR_CAPTIONTEXT = 9
Private Const COLOR_ACTIVEBORDER = 10
Private Const COLOR_INACTIVEBORDER = 11
Private Const COLOR_APPWORKSPACE = 12
Private Const COLOR_HIGHLIGHT = 13
Private Const COLOR_HIGHLIGHTTEXT = 14
Private Const COLOR_BTNFACE = 15
Private Const COLOR_BTNSHADOW = 16
Private Const COLOR_GRAYTEXT = 17
Private Const COLOR_BTNTEXT = 18
Private Const COLOR_INACTIVECAPTIONTEXT = 19
Private Const COLOR_BTNHIGHLIGHT = 20
Private Const COLOR_3DDKSHADOW = 21
Private Const COLOR_3DFACE = COLOR_BTNFACE
Private Const COLOR_3DHIGHLIGHT = COLOR_BTNHIGHLIGHT
Private Const COLOR_3DHILIGHT = COLOR_BTNHIGHLIGHT
Private Const COLOR_3DLIGHT = 22
Private Const COLOR_3DSHADOW = COLOR_BTNSHADOW
Private Const COLOR_BTNHILIGHT = COLOR_BTNHIGHLIGHT
Private Const COLOR_DESKTOP = COLOR_BACKGROUND
Private Const COLOR_INFOBK = 24
Private Const COLOR_INFOTEXT = 23

Private Sub RaiseSysColorError(Optional errval)
    If IsMissing(errval) Then
        RaiseError DWERR_APIRESULT, "dwSysColor"
    Else
        RaiseError errval, "dwSysColor"
    End If
End Sub

Public Function GetSysColor(ByVal lpSysColor As Integer) As Long
Attribute GetSysColor.VB_HelpID = 2982
    GetSysColor = apiGetSysColor(lpSysColor)
End Function

Public Sub SetSysColors(ByVal lpSysColor As Integer, ByVal lpColorValue As Long)
Attribute SetSysColors.VB_HelpID = 2983
Attribute SetSysColors.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim newcolor As Long
    Dim idx As Long
    Dim res As Long
    
    idx = lpSysColor
    newcolor = lpColorValue
    res = apiSetSysColors(1, idx, newcolor)
    If res& = 0 Then RaiseSysColorError DWERR_APIRESULT
#Else
    Dim newcolor As Long
    Dim idx As Integer
    
    idx = lpSysColor
    newcolor = lpColorValue
    apiSetSysColors 1, idx, newcolor
#End If
End Sub

Public Property Get SCROLLBAR() As Long
    SCROLLBAR = GetSysColor(COLOR_SCROLLBAR)
End Property

Public Property Let SCROLLBAR(ByVal newcolor&)
    Call SetSysColors(COLOR_SCROLLBAR, newcolor&)
End Property

Public Property Get background() As Long
    background = GetSysColor(COLOR_BACKGROUND)
End Property

Public Property Let background(ByVal newcolor&)
    Call SetSysColors(COLOR_BACKGROUND, newcolor&)
End Property

Public Property Get ACTIVECAPTION() As Long
    ACTIVECAPTION = GetSysColor(COLOR_ACTIVECAPTION)
End Property

Public Property Let ACTIVECAPTION(ByVal newcolor&)
    Call SetSysColors(COLOR_ACTIVECAPTION, newcolor&)
End Property

Public Property Get INACTIVECAPTION() As Long
    INACTIVECAPTION = GetSysColor(COLOR_INACTIVECAPTION)
End Property

Public Property Let INACTIVECAPTION(ByVal newcolor&)
    Call SetSysColors(COLOR_INACTIVECAPTION, newcolor&)
End Property

Public Property Get MENU() As Long
    MENU = GetSysColor(COLOR_MENU)
End Property

Public Property Let MENU(ByVal newcolor&)
    Call SetSysColors(COLOR_MENU, newcolor&)
End Property

Public Property Get WINDOW() As Long
    WINDOW = GetSysColor(COLOR_WINDOW)
End Property

Public Property Let WINDOW(ByVal newcolor&)
    Call SetSysColors(COLOR_WINDOW, newcolor&)
End Property

Public Property Get WINDOWFRAME() As Long
    WINDOWFRAME = GetSysColor(COLOR_WINDOWFRAME)
End Property

Public Property Let WINDOWFRAME(ByVal newcolor&)
    Call SetSysColors(COLOR_WINDOWFRAME, newcolor&)
End Property

Public Property Get MENUTEXT() As Long
    MENUTEXT = GetSysColor(COLOR_MENUTEXT)
End Property

Public Property Let MENUTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_MENUTEXT, newcolor&)
End Property

Public Property Get WINDOWTEXT() As Long
    WINDOWTEXT = GetSysColor(COLOR_WINDOWTEXT)
End Property

Public Property Let WINDOWTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_WINDOWTEXT, newcolor&)
End Property

Public Property Get CAPTIONTEXT() As Long
    CAPTIONTEXT = GetSysColor(COLOR_CAPTIONTEXT)
End Property

Public Property Let CAPTIONTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_CAPTIONTEXT, newcolor&)
End Property

Public Property Get ACTIVEBORDER() As Long
    ACTIVEBORDER = GetSysColor(COLOR_ACTIVEBORDER)
End Property

Public Property Let ACTIVEBORDER(ByVal newcolor&)
    Call SetSysColors(COLOR_ACTIVEBORDER, newcolor&)
End Property

Public Property Get INACTIVEBORDER() As Long
    INACTIVEBORDER = GetSysColor(COLOR_INACTIVEBORDER)
End Property

Public Property Let INACTIVEBORDER(ByVal newcolor&)
    Call SetSysColors(COLOR_INACTIVEBORDER, newcolor&)
End Property

Public Property Get APPWORKSPACE() As Long
    APPWORKSPACE = GetSysColor(COLOR_APPWORKSPACE)
End Property

Public Property Let APPWORKSPACE(ByVal newcolor&)
    Call SetSysColors(COLOR_APPWORKSPACE, newcolor&)
End Property

Public Property Get HIGHLIGHT() As Long
    HIGHLIGHT = GetSysColor(COLOR_HIGHLIGHT)
End Property

Public Property Let HIGHLIGHT(ByVal newcolor&)
    Call SetSysColors(COLOR_HIGHLIGHT, newcolor&)
End Property

Public Property Get HIGHLIGHTTEXT() As Long
    HIGHLIGHTTEXT = GetSysColor(COLOR_HIGHLIGHTTEXT)
End Property

Public Property Let HIGHLIGHTTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_HIGHLIGHTTEXT, newcolor&)
End Property

Public Property Get BTNFACE() As Long
    BTNFACE = GetSysColor(COLOR_BTNFACE)
End Property

Public Property Let BTNFACE(ByVal newcolor&)
    Call SetSysColors(COLOR_BTNFACE, newcolor&)
End Property

Public Property Get BTNSHADOW() As Long
    BTNSHADOW = GetSysColor(COLOR_BTNSHADOW)
End Property

Public Property Let BTNSHADOW(ByVal newcolor&)
    Call SetSysColors(COLOR_BTNSHADOW, newcolor&)
End Property

Public Property Get GRAYTEXT() As Long
    GRAYTEXT = GetSysColor(COLOR_GRAYTEXT)
End Property

Public Property Let GRAYTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_GRAYTEXT, newcolor&)
End Property

Public Property Get BTNTEXT() As Long
    BTNTEXT = GetSysColor(COLOR_BTNTEXT)
End Property

Public Property Let BTNTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_BTNTEXT, newcolor&)
End Property

Public Property Get INACTIVECAPTIONTEXT() As Long
    INACTIVECAPTIONTEXT = GetSysColor(COLOR_INACTIVECAPTIONTEXT)
End Property

Public Property Let INACTIVECAPTIONTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_INACTIVECAPTIONTEXT, newcolor&)
End Property

Public Property Get BTNHIGHLIGHT() As Long
    BTNHIGHLIGHT = GetSysColor(COLOR_BTNHIGHLIGHT)
End Property

Public Property Let BTNHIGHLIGHT(ByVal newcolor&)
    Call SetSysColors(COLOR_BTNHIGHLIGHT, newcolor&)
End Property

Public Property Get DKSHADOW3D() As Long
' Note reversed function name (3D at end)
    DKSHADOW3D = GetSysColor(COLOR_3DDKSHADOW)
End Property

Public Property Let DKSHADOW3D(ByVal newcolor&)
    Call SetSysColors(COLOR_3DDKSHADOW, newcolor&)
End Property

Public Property Get DFACE3D() As Long
    DFACE3D = GetSysColor(COLOR_3DFACE)
End Property

Public Property Let FACE3D(ByVal newcolor&)
    Call SetSysColors(COLOR_3DFACE, newcolor&)
End Property

Public Property Get HIGHLIGHT3D() As Long
    HIGHLIGHT3D = GetSysColor(COLOR_3DHIGHLIGHT)
End Property

Public Property Let HIGHLIGHT3D(ByVal newcolor&)
    Call SetSysColors(COLOR_3DHIGHLIGHT, newcolor&)
End Property

Public Property Get HILIGHT3D() As Long
    HILIGHT3D = GetSysColor(COLOR_3DHILIGHT)
End Property

Public Property Let HILIGHT3D(ByVal newcolor&)
    Call SetSysColors(COLOR_3DHILIGHT, newcolor&)
End Property

Public Property Get LIGHT3D() As Long
    LIGHT3D = GetSysColor(COLOR_3DLIGHT)
End Property

Public Property Let LIGHT3D(ByVal newcolor&)
    Call SetSysColors(COLOR_3DLIGHT, newcolor&)
End Property

Public Property Get SHADOW3D() As Long
    SHADOW3D = GetSysColor(COLOR_3DSHADOW)
End Property

Public Property Let SHADOW3D(ByVal newcolor&)
    Call SetSysColors(COLOR_3DSHADOW, newcolor&)
End Property

Public Property Get BTNHILIGHT() As Long
    BTNHILIGHT = GetSysColor(COLOR_BTNHILIGHT)
End Property

Public Property Let BTNHILIGHT(ByVal newcolor&)
    Call SetSysColors(COLOR_BTNHILIGHT, newcolor&)
End Property

Public Property Get DESKTOP() As Long
    DESKTOP = GetSysColor(COLOR_DESKTOP)
End Property

Public Property Let DESKTOP(ByVal newcolor&)
    Call SetSysColors(COLOR_DESKTOP, newcolor&)
End Property

Public Property Get INFOBK() As Long
    INFOBK = GetSysColor(COLOR_INFOBK)
End Property

Public Property Let INFOBK(ByVal newcolor&)
    Call SetSysColors(COLOR_INFOBK, newcolor&)
End Property

Public Property Get INFOTEXT() As Long
    INFOTEXT = GetSysColor(COLOR_INFOTEXT)
End Property

Public Property Let INFOTEXT(ByVal newcolor&)
    Call SetSysColors(COLOR_INFOTEXT, newcolor&)
End Property


