

SysColor -- A Windows 3.0 System-Color Utility

by Tom Swan


SysColor lets you change all of Window's system-color settings, 
including the colors for elements such as the menu highlighter, which 
the standard Color utility can't modify. The program listing, 
SYSCOLOR.PAS, first appeared in the Borland Language Express, Volume 1, 
Number 2, in my article, "ObjectWindows: A Taste of Turbo Pascal for 
Windows," and is also printed in my book "Turbo Pascal for Windows 3.0 
Programming" (Bantam, 1991).

All source code and resources are included with SysColor. To compile the 
program, load SYSCOLOR.PAS into the TPW editor and press F9. The 
program's resources are stored in binary form in file SYSCOLOR.RES, and 
in text form in files SYSCOLOR.DLG, SYSCOLOR.ICO, and SYSCOLOR.RC.


Using SysColor 

Figure 1 shows SysColor's display. The three scroll bars at upper left 
adjust red, green, and blue values, which are mixed and displayed in the 
large Color sample rectangle at midscreen. Use a mouse to adjust the 
sliders and select from over 16 million color combinations, most of 
which are dithered (mixed from other solid colors) because few if any 
PCs can display 16 million hues at once. 



Figure 1: SysColor's display

While running SysColor, you'll notice that a mouse is required. Of 
course, you can use TPW to write code that supports a keyboard, but in 
order to keep SysColor's interface as simple as possible, I opted to 
forego keyboard support. If you don't have a mouse, you can run SysColor 
and use the menu's commands, but you won't be able to change your 
system's colors. 

To change a system color, click on one of the labeled color bars at 
right, hold down the mouse button, and drag the color to the bar you 
want to change. Release the mouse to copy the dragged color to the new 
location. To cancel the change, release the mouse outside any color bar. 
You can drag colors from the large sample square, or from any color bar 
to any other bar. Click a bar to copy its color to the large sample. You 
can then use the red, green, and blue scroll bars to adjust the color 
and drag the new color back to its original bar or to another one. 




SysColor's Menu

SysColor has a simple menu displayed at the top of the window. In the 
menu, the first command, "About SysColor..." displays the ubiquitous 
About Dialog box, a standard object that TPW supports with a minimum of 
commands (see Figure 2). Also see procedure SCWindow.CMAbout in the 
SYSCOLOR.PAS listing. Select the Exit command to end the program. Or, to 
quit SysColor, you can press Alt+F4 or select Close from the program's 
System menu. 



Figure 2: SysColor's About box

After changing various color settings, click the Set button to transfer 
your colors to Windows. For example, for a racy display, set the Window 
color bar to bright red, then click Set. Click Reset if flaming red 
windows aren't your style. Depending on your display's color 
capabilities, Windows attempts to find matching display colors for the 
colors you choose, so for some settings, the results may be different 
from the displayed samples. For instance, on my system, which I usually 
run in 16-color 800-by-600 resolution, setting the Window color bar to 
cranberry (Red=175, Green=60, Blue=124) actually paints windows deep 
purple. Apparently, this effect is due to Windows' rejection of dithered 
colors for some settings. 

Click the Save button to save the current set of color bars to a file 
named SYSCOLOR.INI in your Windows directory. The next time you run 
SysColor, the program will display those same colors. If in the meantime 
you changed any system colors but did not save the changes to 
SYSCOLOR.INI, the color bars may not match those currently in use. In 
that case, click the Reset button to resynch the color bars. 

While using SysColor, keep one fact in mind: clicking the Set button is 
the only way to change Windows' colors. No changes take effect until you 
click Set, and even then color settings are temporary. You can still use 
the Windows Color utility to select alternate colors independently of 
SysColor. 


Loading Colors Automatically 

After saving your favorite colors in SYSCOLOR.INI, you can configure 
SysColor to select those colors automatically when you start Windows. To 
do that, use the NotePad to edit SYSCOLOR.INI, and after the last line, 
add the command nonstop=true. The next time you run SysColor, the 
program will load SYSCOLOR.INI and then "press" the Set and Quit buttons 
automatically. 

Or, you can put SysColor into autopilot mode by using the "nonstop" 
command-line switch -n. Select the File or Program Manager Run command. 
Type SYSCOLOR -n to load and set the colors from SYSCOLOR.INI. Either 
way, with nonstop on, SysColor will exit immediately after setting the 
system's colors. 

To run the program normally again, you could remove the nonstop=true 
command from SYSCOLOR.INI or change the command to nonstop=false, but an 
easier method is to run SysColor with the "stop" command-line switch, -
s, which overrides the nonstop setting. A good place to use -s is in the 
Program Manager's File:Properties command. On my system, I use that 
command to set SysColor's Command Line to C:\WINDOWS\SYSCOLOR.EXE -s. I 
also modify the RUN command in WIN.INI to read 

run=syscolor.exe 

With these settings, SysColor sets my system's colors every time I start 
Windows. Running SysColor with the -s switch lets me use the program 
normally to make additional color adjustments. 

Hint: If you have a color display, use SysColor to set Highlight to 
turquoise (Red=0, Green=255, Blue=255) and Highlight Text to black for 
more colorful menus, items that the standard Windows Color utility does 
not let you change.
