The Moth
Developer, Former MVP, now at Microsoft - Best of
2004
,
2005
,
2006
,
2007
,
2008
,
2009
« Blog link of the week 14
|
Home
|
April MVP chat »
SystemColorsEx
Mon, April 11, 2005, 02:56 PM under
MobileAndEmbedded
Recently I needed to change scrollbar colors, the disabled text color and other similar items. The target is a Windows CE device (
not
a PPC) and I quickly found (through the control panel) the Display Properties dialog and specifically
the "Appearance" tab
. If you don't have a WinCE device, launch the 4.1 emulator that ships with VS.NET 2003 to check it out.
So there was my goal: to find out what it does under the covers in order to offer us changing colors of individual items (e.g. Active Title Bar color) and also the overall scheme (e.g. Brick). We start at the obvious place: *everything* on this platform is stored in the registry. Using the Remote Registry editor (that comes with
eVC
) we take a snapshot before and after a scheme change and then use
windiff
(or similar) to spot the difference. Bingo; we find a string value "Current" under HKCU that stores the scheme name and, more importantly, we find a byte array value "SysColor" under HKLM that stores the color data. Searching on MSDN proves fruitful and informative, leading us to
this
and
this
. We test out our understanding by changing some of the RGB values in the registry, flush, reset the unit and the changes take effect. Nice!
Next step is to figure out how the control panel applet applies the change on the fly. We suspect some windows message and decide to investigate further with another eVC tool, remote spy++. Every time we apply a change a
WM_SYSCOLORCHANGE
message is broadcast. So we try with our own app to change the registry and then broadcast the same message but no effect takes place. Wouldn't it be great if we had the source code to the OS dialog so we could see exactly what it does? But wait, I have
platform builder
installed on this machine, so I could locate the code and check it out! After a few hit and miss searches, I nail it down. They call an API that does both the writing to the registry and the broadcast and the on-the-fly change:
SetSysColors
Note that, if you don't care about changing colors and all you need is read-only access, then the existing
System.Drawing.SystemColors
class fits the bill.
This has been a not so short story, leading up to providing you with a managed class that wraps all of the above. Use it in your own WinCE (not-PPC) projects for changing color themes on the fly or single element color changes.
Download the VB class here
.
Get the
C# version
as part of the SDF (guest, guest).
Comments [0]
|
Permalink
Comments are closed.
About
My team's page on MSDN
Subscribe
Contact Form
My screencasts on channel9
Tags
AboutPresenting (5)
Blogging (7)
Career (5)
Communication (5)
dotNET (120)
Events (93)
GPGPU (2)
HPC (6)
IE7 RSS (6)
Links (129)
LINQ (23)
MobileAndEmbedded (148)
Orcas (128)
ParallelComputing (63)
Personal (32)
Random (42)
SideShow (12)
Silverlight (17)
SoftwareProcess (3)
UAC (14)
UserInterfaceDesign (5)
Vista (84)
VisualStudio (112)
Whidbey (31)
Windows (90)
WindowsServer2008 (3)
Latest Posts
Parallel Computing Platform Developer Lab
Slides and code for MPI Cluster Debugger
DirectCompute
GPGPU
Code for Parallelism Features Tour
Managed code and the Shell – Do?
Dev Lead Job opening on my team
Best of "The Moth" 2009
Bug Triage
Parallel Computing Features Tour in VS2010
MPI Cluster Debugger launch integration in VS2010
Parallel Debugging
"Parallel Programming Talk" show
Message Passing Interface (MPI)
Windows HPC Server links
Extension Manager in Visual Studio 2010
Core debugger enhancements in VS2010
Dump debugging with Parallel Stacks
Slides for Parallel Debugging windows
MPI Project Template for VS2010
Archives
March, 2010 (2)
February, 2010 (3)
January, 2010 (3)
December, 2009 (1)
November, 2009 (11)
October, 2009 (12)
September, 2009 (1)
August, 2009 (6)
July, 2009 (5)
June, 2009 (3)
May, 2009 (7)
April, 2009 (5)
March, 2009 (3)
February, 2009 (4)
January, 2009 (6)
December, 2008 (3)
November, 2008 (12)
October, 2008 (6)
September, 2008 (9)
August, 2008 (5)
July, 2008 (5)
June, 2008 (8)
May, 2008 (18)
April, 2008 (11)
March, 2008 (13)
February, 2008 (17)
January, 2008 (15)
December, 2007 (20)
November, 2007 (25)
October, 2007 (19)
September, 2007 (11)
August, 2007 (31)
July, 2007 (24)
June, 2007 (19)
May, 2007 (24)
April, 2007 (18)
March, 2007 (35)
February, 2007 (34)
January, 2007 (17)
December, 2006 (18)
November, 2006 (17)
October, 2006 (23)
September, 2006 (22)
August, 2006 (15)
July, 2006 (15)
June, 2006 (13)
May, 2006 (10)
April, 2006 (5)
March, 2006 (1)
February, 2006 (1)
January, 2006 (2)
December, 2005 (5)
November, 2005 (4)
October, 2005 (3)
September, 2005 (8)
August, 2005 (17)
July, 2005 (11)
June, 2005 (7)
May, 2005 (24)
April, 2005 (15)
March, 2005 (15)
February, 2005 (18)
January, 2005 (23)
December, 2004 (24)
November, 2004 (25)
October, 2004 (10)
September, 2004 (23)
August, 2004 (12)
July, 2004 (1)