PC Review


Reply
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average.

Screen Color

 
 
Zach
Guest
Posts: n/a
 
      10th Jun 2011
Using the code below I can change the screen color.
How can I ascertain the colors as they are before changung them, so I can
change the colors back to what they were upon leaving the application?

Zach.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Vocab
{
public partial class ScrColor1 : Form
{
const int COLOR_DESKTOP = 1;
[DllImport("user32.dll")]
public static extern bool SetSysColors(int cElements, int[]
lpaElements, uint[] lpaRgbValues);
int[] aiElements = {COLOR_DESKTOP};
uint RGB(byte byRed, byte byGreen, byte byBlue)
{
uint res = byBlue;
res = res << 8;
res += byGreen;
res = res << 8;
res += byRed;
return res;
}
public ScrColor1()
{
InitializeComponent();
uint[] aColors = { RGB(100,50,150) };
SetSysColors(1, aiElements, aColors);
}
}
}

 
Reply With Quote
 
 
 
 
Zach
Guest
Posts: n/a
 
      10th Jun 2011
Sorry about the wording

How can I ascertain the colors as they were before changing them?
Obviously I will want to do that before I change them.


"Zach" <(E-Mail Removed)> wrote in message
news:4df21944$0$30714$(E-Mail Removed)...
> Using the code below I can change the screen color.
> How can I ascertain the colors as they are before changung them, so I can
> change the colors back to what they were upon leaving the application?
>
> Zach.
>
> using System;
> using System.Collections.Generic;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Text;
> using System.Windows.Forms;
> using System.Runtime.InteropServices;
>
> namespace Vocab
> {
> public partial class ScrColor1 : Form
> {
> const int COLOR_DESKTOP = 1;
> [DllImport("user32.dll")]
> public static extern bool SetSysColors(int cElements, int[]
> lpaElements, uint[] lpaRgbValues);
> int[] aiElements = {COLOR_DESKTOP};
> uint RGB(byte byRed, byte byGreen, byte byBlue)
> {
> uint res = byBlue;
> res = res << 8;
> res += byGreen;
> res = res << 8;
> res += byRed;
> return res;
> }
> public ScrColor1()
> {
> InitializeComponent();
> uint[] aColors = { RGB(100,50,150) };
> SetSysColors(1, aiElements, aColors);
> }
> }
> }


 
Reply With Quote
 
 
 
 
Jeff Gaines
Guest
Posts: n/a
 
      10th Jun 2011
On 10/06/2011 in message <4df21944$0$30714$(E-Mail Removed)> Zach
wrote:

>How can I ascertain the colors as they are before changung them, so I can
>change the colors back to what they were upon leaving the application?


If your application changed my desktop colours it would fly out the window
fast enough to cause a sonic boom.

--
Jeff Gaines Wiltshire UK
You can't tell which way the train went by looking at the tracks
 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      10th Jun 2011

"Jeff Gaines" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 10/06/2011 in message <4df21944$0$30714$(E-Mail Removed)> Zach
> wrote:
>
>>How can I ascertain the colors as they are before changung them, so I can
>>change the colors back to what they were upon leaving the application?

>
> If your application changed my desktop colours it would fly out the window
> fast enough to cause a sonic boom.
>
> --
> Jeff Gaines Wiltshire UK
> You can't tell which way the train went by looking at the tracks


There was a guy who jumped off the Eifel tower in Paris because he thought
he could fly: family?

 
Reply With Quote
 
Lee J. Moore
Guest
Posts: n/a
 
      10th Jun 2011
On Fri, 10 Jun 2011 15:16:48 +0200, Zach wrote:

> Using the code below I can change the screen color. How can I ascertain
> the colors as they are before changung them, so I can change the colors
> back to what they were upon leaving the application?


This seems too obvious so maybe I'm missing something, but have you tried
GetSysColor() with the COLOR_DESKTOP parameter?

--
Lee J. Moore
Cheshire, UK

"He who knows, does not speak. He who speaks, does not know." - Lao Tzu
 
Reply With Quote
 
Lee J. Moore
Guest
Posts: n/a
 
      10th Jun 2011
On Fri, 10 Jun 2011 14:25:06 +0000, Lee J. Moore wrote:

> On Fri, 10 Jun 2011 15:16:48 +0200, Zach wrote:
>
>> Using the code below I can change the screen color. How can I ascertain
>> the colors as they are before changung them, so I can change the colors
>> back to what they were upon leaving the application?

>
> This seems too obvious so maybe I'm missing something, but have you
> tried GetSysColor() with the COLOR_DESKTOP parameter?


Further to this, there's an example of how to do it in the MSDN library:

http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

--
Lee J. Moore
Cheshire, UK

"He who knows, does not speak. He who speaks, does not know." - Lao Tzu
 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      10th Jun 2011
"Zach" <(E-Mail Removed)> wrote in message
news:4df21944$0$30714$(E-Mail Removed)...

> SetSysColors(1, aiElements, aColors);


Honestly, since the setter is called SETSysColors did you never think to
look for GETSysColors or something similar? (In fact, the function you want
is explicitly mentioned in the help for SetSysColors.)

And really, WHY do you think you need to change colors? (I'm sure 99.9999%
of the folks in here believe you really only THINK you need to change them.)
It's one of the rudest things you can do to your user. I realize that you
are at least showing the decency to want to return them to their previous
state when you're done, but we've seen questions like this for years and
years and I personally have yet to see anyone present a good excuse for
doing this.


 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      10th Jun 2011
"Lee J. Moore" <(E-Mail Removed)> wrote in message
news:ist9k2$5i2$(E-Mail Removed)...
> On Fri, 10 Jun 2011 14:25:06 +0000, Lee J. Moore wrote:
>
>> On Fri, 10 Jun 2011 15:16:48 +0200, Zach wrote:
>>
>>> Using the code below I can change the screen color. How can I ascertain
>>> the colors as they are before changung them, so I can change the colors
>>> back to what they were upon leaving the application?

>>
>> This seems too obvious so maybe I'm missing something, but have you
>> tried GetSysColor() with the COLOR_DESKTOP parameter?

>
> Further to this, there's an example of how to do it in the MSDN library:
>
> http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
>
> --
> Lee J. Moore
> Cheshire, UK
>
> "He who knows, does not speak. He who speaks, does not know." - Lao Tzu


Thank you very much!

Zach.

 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      10th Jun 2011
"Jeff Johnson" <(E-Mail Removed)> wrote in message
news:ist9k3$7h1$(E-Mail Removed)...
> "Zach" <(E-Mail Removed)> wrote in message
> news:4df21944$0$30714$(E-Mail Removed)...
>
>> SetSysColors(1, aiElements, aColors);

>
> Honestly, since the setter is called SETSysColors did you never think to
> look for GETSysColors or something similar? (In fact, the function you
> want is explicitly mentioned in the help for SetSysColors.)
>
> And really, WHY do you think you need to change colors? (I'm sure 99.9999%
> of the folks in here believe you really only THINK you need to change
> them.) It's one of the rudest things you can do to your user. I realize
> that you are at least showing the decency to want to return them to their
> previous state when you're done, but we've seen questions like this for
> years and years and I personally have yet to see anyone present a good
> excuse for doing this.



Dear Mr. Jeff Johnson,
Colors change perceptually, depending on the adjacent colors,
or put differently, a given color might look beautiful against a
certain background color, but change the background color
and it might look awful. Therefore there might be good cause
to do something about the background color. And as to your
value judgmets, you can do with them what a monkey does
with its nuts.

Zach.




 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      10th Jun 2011
"Peter Duniho" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 6/10/11 7:05 AM, Zach wrote:
>> [...]
>>> If your application changed my desktop colours it would fly out the
>>> window fast enough to cause a sonic boom.

>>
>> There was a guy who jumped off the Eifel tower in Paris because he
>> thought he could fly: family?

>
> I think you missed the point. It's not Jeff who would fly. It's YOUR
> program that would. And with good cause.
>
> And frankly, no one ought to be messing around with the API, managed or
> unmanaged (as in your case) without actually reading the documentation.
> And the documentation for SetSysColors() includes exactly the information
> you are looking for.
>
> If you _must_ muck with the user's global settings, at least read the docs
> first.
>
> Pete

Pete, I know you to be a nice person, this makes me sad.
Zach.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Color Codes: Different color with same color Index Ryan H Microsoft Excel Programming 0 5th Feb 2010 05:42 PM
color transition (color changes from dark color to light color) color transition Microsoft Powerpoint 2 21st Nov 2009 01:21 PM
Color color! Cell color! mhax Microsoft Excel Programming 5 3rd Aug 2006 02:24 PM
AIO color & BW print, color & BW copy, pcfax, color scan A. L. Shaw, MD Printers 2 14th Jan 2006 05:44 AM
Fill Color/ Background Color/Tab Color M.Cave Microsoft Excel Misc 2 11th Oct 2004 02:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.