WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Display

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Changing System Colors

Keywords:   system colors

Question:

How do you change system colors?

Answer:

It is easy to write to the registry and update it to specify the system colors to be used on the next restart of Windows.

It is somewhat more complicated to change the system colors for the current session. The code below shows how to do both.


;Note: This code only seems to work when in Windows Classic view mode. It doesn't seem to
;work in XP theme view mode.

element_string = "ActiveTitle"; From registry dataitem name
element_offset = 2; Code from table below 
color_red      = 255; red color value 0 to 255
color_green    = 0; green color value 0 to 255
color_blue     = 0; blue color value 0 to 255
;--------------------------------------- 

; This code sets the colors for the next restart.  Easy
RegSetValue(@REGCURRENT, "Control Panel\Colors\[%element_string%]", "%color_red% %color_green% %color_blue%")
; End of Next Restart code. 


;This code sets the colors for the current session
elements_buf = binaryalloc(4)
values_buf = binaryalloc(4) 
BinaryPoke4(elements_buf, 0, element_offset)
BinaryPoke4(values_buf, 0, color_red | (color_green << 8) | (color_blue << 16))
DaDll=strcat(DirWindows(1),"USER32.DLL")
DllCall(DaDll, long:"SetSysColors", word:1, lpbinary:elements_buf, lpbinary:values_buf) 
BinaryFree(elements_buf)
BinaryFree(values_buf)
exit
;End of current session code exit
;;;;;
;Color offsets:
; 0  COLOR_SCROLLBAR
; 1  COLOR_BACKGROUND
; 2  COLOR_ACTIVECAPTION
; 3  COLOR_INACTIVECAPTION
; 4  COLOR_MENU
; 5  COLOR_WINDOW
; 6  COLOR_WINDOWFRAME
; 7  COLOR_MENUTEXT
; 8  COLOR_WINDOWTEXT
; 9  COLOR_CAPTIONTEXT
;10  COLOR_ACTIVEBORDER
;11  COLOR_INACTIVEBORDER
;12  COLOR_APPWORKSPACE
;13  COLOR_HIGHLIGHT
;14  COLOR_HIGHLIGHTTEXT
;15  COLOR_BTNFACE
;16  COLOR_BTNSHADOW
;17  COLOR_GRAYTEXT
;18  COLOR_BTNTEXT
;19  COLOR_INACTIVECAPTIONTEXT
;20  COLOR_BTNHIGHLIGHT
;21  COLOR_3DDKSHADOW
;22  COLOR_3DLIGHT
;23  COLOR_INFOTEXT
;24  COLOR_INFOBK




Note: the above code works fine if you have the desktop set to windows classic. It will change the background in XP style but this is masked by any wallpaper or open window. The magic of changing system colors in windows classic is that the windows title bars change color as well. In XP this does not happen.

I am trying to find a way of showing users which environment they are in which remains visible at all times without taking up too much room. I could resort to a status bar display but this adds clutter to an already crowded area.

Answer:

I did a quick search out at Google Groups and found this thread:

http://groups-beta.google.com/group/microsoft.public.win32.programmer.kernel/browse_frm/thread/2f3c613e7d69639e/e6763fc26f8d5172?q=SetSysColors+XP&_done=%2Fgroups%3Fq%3DSetSysColors+XP%26&_doneTitle=Back+to+Search&&d#e6763fc26f8d5172

It basically suggests you create and install your own theme files. Please refer this MSDN document for the information:

http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/userex/themesinstaller.asp?frame=true

And for the visual style, please refer this page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/themes.asp


Article ID:   W13209
Filename:   Change System Colors.txt
File Created: 2005:01:27:08:55:04
Last Updated: 2005:01:27:08:55:04