?
Solved

How to change Windows Color Scheme

Posted on 2001-07-20
15
Medium Priority
?
945 Views
Last Modified: 2010-04-06
My project is something like the Desktop Theme Manager in Windows 98 (difference is that it's in the background). I want to maintain the desktop settings of >100 Company PCs running Win98. My program runs after every logon. The purpose of this is to discard any changes made by the users. They seem to bypass the security.

I have successfully changed the wallpaper to the company logo by updating the registry and calling SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, 0, SPIF_SENDWININICHANGE).  I have also updated the color settings in HKEY_CURRENT_USER\Control Panel\...

My problem is that I cannot tell Windows to refresh so that the new color scheme will take effect. When I looked at the Display properties, the change was reflected. Broadcasting WM_SYSCOLORCHANGE doesn't work.  SetSysColors can change the colors but the settings are lost after the logoff/shutdown.  I've read about SetSystemPaletteUse in the SDK but I don't seem to understand the documentation.
0
Comment
Question by:piscean
  • 5
  • 3
  • 3
  • +4
15 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6304402
Hello

  SetSysColors will not store the new value in the registry edit, so you need to store the value you choosed to the registry edit, windows store that in this key

[HKEY_CURRENT_USER\Control Panel\Colors]
"Background"="58 110 165"

if you change the color scheme to black the value will stroe in the registry as

[HKEY_CURRENT_USER\Control Panel\Colors]
"Background"="0 0 0"

Best regards
Mohammed Nasman

0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6304439
Just remember the color store as RGB value
use RGB(R,G,B) and GetRValue,GetGValue,GetBValue
they will help you to get the color value for each color

Mohammed
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6304451
You said:

(1) I have also updated the color settings in HKEY_CURRENT_USER\Control Panel\...
(2) SetSysColors can change the colors but the settings are lost after the logoff/shutdown.  

Don't the two things in combination solve the problem? (2) sets the colors right now, (1) after the next logoff/shutdown.

Regards, Madshi.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6304529
Hello

  here's a simple sample it will change the background of desktop by using SetSysColors, and also will write to registry and save the values, and when you log off and back you will see the setting you choosed


//====
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ColorDialog1: TColorDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  I,J : Integer;
  Reg : TRegistry;
  R,G,B : string;
begin
  Reg := TRegistry.Create;
  Reg.RootKey := HKEY_CURRENT_USER;
  I := COLOR_DESKTOP;
  if ColorDialog1.Execute then
    J := ColorDialog1.Color;
  R := IntTostr(GetRvalue(J));
  G := IntTostr(GetGvalue(J));
  B := IntTostr(GetBvalue(J));
  SetSysColors(1,I,J);
  if Reg.OpenKey('Control Panel\Colors',False) then
    Reg.WriteString('Background',R + ' '+ G + ' ' + B);
  SetSysColors(1,I,J);
  Reg.Free;
end;

end.

Mohammed
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6304653
I think you would be better off just exporting the appropropriate HKCU and placing the hive key file in a hidden folder. Then at HKLM\Software\Microsoft\Windows\CurrentVersion\Run
Put in a command:
c:\windows\regedit32.exe /s 'c:\filename.reg'
where filename is the name you called the exported hive file. This will silent install the settings on the machine.  When the user logs on the hive file is updated. You can put your wall paper settings and anything else in the machine you want as well.

If you still have problems write a small batch file that AutoExec.bat would call. This batch file would have a command in it to run c:\windows\regedit32.exe /s 'c:\filename.reg'

I do this at work all the time and it works great for me, but I do it for different reasons.

0
 
LVL 1

Author Comment

by:piscean
ID: 6307399
Thanks for your help guys.  But I can do change the color scheme (In a somewhat long process...  change the registry and call SetSysColors to fool the user of the refresh).  What I really wanted to know is that if there's a message I have to broadcast after I've changed the color settings in HKEY_CURRENT_USER\Control Panel\Colors.  As you can see in the case of the wallpaper, after I've changed HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper (and other values there ...), I have to broadcast a WM_SETTINGCHANGE to all windows to make the change in effect (or to trigger a refresh).

Is there a message that corresponds to refreshing after the color changes made?
0
 
LVL 1

Author Comment

by:piscean
ID: 6307407
gemarti,
I've tried that before and it does change the registry setting.  But I need an immediate refresh after the change which importing to registry cannot do.
Thanks anyway ...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6307409
No, I'm sorry. At least no documented message. There are a lot of registry values that get loaded only when Windows or the explorer starts up, and never again until the next reboot. And only a few things react on WM_SETTINGCHANGE.

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:inthe
ID: 6307474
>>SetSysColors to fool the user of the refresh

to do a refresh jstsnd f5 to the desktop.


that wont refresh the registry or your colors though..youll need at least a logoff for that key im sure.

0
 
LVL 1

Author Comment

by:piscean
ID: 6307719
What do you guys think are the procedures executed when you changed the settings and clicked OK or Apply in the Display properties?  Changes are reflected immediately (both registry and display) without a restart/logoff isn't it? ...

inthe,
I can't (and should not) force a logoff.  The user must be doing something (poor user ...) ...  BTW, I also am sure there's a way to do this without a logoff ...

Thanks for the comments ...  (can we try harder ...)
0
 
LVL 1

Author Comment

by:piscean
ID: 6307722
I mean "The user might be doing something ..."
0
 
LVL 1

Author Comment

by:piscean
ID: 6307762
I mean "The user might be doing something ..."
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6307957
>> What do you guys think are the procedures executed when you changed the settings and clicked OK or Apply in the Display properties?

Well, there's not much to think about. Windows calls an internal function (like SystemParametersInfoExExEx), no doubt about that. It's just not documented and possibly different in every OS...   :-(

Regards, Madshi.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8711211
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

To be PAQ/Refund

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 8822202
Paq'ed and points not refunded

PashaMod
CS Moderator @Experts Exchange
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question