Desktop Color Settings
Posted: 2019-10-02
By: AndreaTincani
Viewed: 202
Filed Under:
No attachments for this post
Use this code to read or set the current desktop color settings.
Module
Option Explicit
Private Declare Function GetSysColor Lib "user32.dll" (ByVal nindex As Long) As Long
Private Declare Function SetSysColors Lib "user32.dll" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
Public Enum WindowsItem
COLOR_ACTIVEBORDER = 10
COLOR_ACTIVECAPTION = 2
COLOR_APPWORKSPACE = 12
COLOR_BACKGROUND = 1
COLOR_BTNFACE = 15
COLOR_BTNHIGHLIGHT = 20
COLOR_BTNSHADOW = 16
COLOR_BTNTEXT = 18
COLOR_CAPTIONTEXT = 9
COLOR_GRAYTEXT = 17
COLOR_HIGHLIGHT = 13
COLOR_HIGHLIGHTTEXT = 14
COLOR_INACTIVEBORDER = 11
COLOR_INACTIVECAPTION = 3
COLOR_INACTIVECAPTIONTEXT = 19
COLOR_MENU = 4
COLOR_MENUTEXT = 7
COLOR_SCROLLBAR = 0
COLOR_WINDOW = 5
COLOR_WINDOWFRAME = 6
COLOR_WINDOWTEXT = 8
End Enum
Public Function GetWindowsColor(Item As WindowsItem) As OLE_COLOR
GetWindowsColor = GetSysColor(Item)
End Function
Public Sub SetWindowsColor(Item As WindowsItem, Color As OLE_COLOR)
SetSysColors 1, Item, Color
End Sub
Special Instructions
This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.