Screen Color

Z

Zach

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);
}
}
}
 
Z

Zach

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.
 
J

Jeff Gaines

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.
 
Z

Zach

Jeff Gaines said:
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?
 
L

Lee J. Moore

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?
 
J

Jeff Johnson

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.
 
Z

Zach

Jeff Johnson said:
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.
 
Z

Zach

Peter Duniho said:
[...]
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.
 
Z

Zach

rossum said:
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.
Read what you wrote: "a given color might look beautiful against a
certain background color". How is "look beautiful" not a value
judgement?

Now look at "And as to your value judgmets[sic], you can ..."

For your homework go and look at the MS Accessibility guidelines, and
think very very carefully about changing the visual display on someone
else's computer unless you have tested your application for
readability for someone who is red-green colourblind and also with
people with every other possible foerm of visual impairment.

Having done that, reconsider and don't mess with someone else's
display colours.

rossum

You, and the others that took the high road, might have asked
whether the application will be used by others, or whether it is
for my private use. That would have saved a couple of bouts
of hysteria.

Zach.
 
Z

Zach Maslin

Peter Duniho said:
Absent any indication on your part, we cannot assume it's a program only
to be used by you, nor is there any point in us wasting time grilling you
about the specific user scenarios. This is a public forum, and questions
such as yours that are stated in a general way must be answered in a
general way, lest other readers get the wrong idea.

Frankly, if you were so cognizant of the importance of not mucking with
global user settings like that, it seems to me that you would have stated
from the outset that you were aware of that importance and explained why
that importance is not relevant in this particular case. The lack of any
such explanation suggests that you really hadn't considered the broader
implications of your question.

Certainly, you _should_ have done so and it was not unreasonable for any
of the rest of us to make the assumption that you were not aware of that
importance and in need of the information, nor to take the position that
even if you were aware of that information, the information needed to be
stated publicly in this thread, so that other readers don't get the wrong
idea.

I also don't know why it would make you sad to be told to read the
documentation. Sorry if that seems offensive to you; it's just plain,
good advice.

Pete

p.s. The "high road" is generally considered a _good_ thing to take. You
seem to mean it otherwise, but if you want to criticize other people for
their behavior, you might as well get your idioms right. :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dear Pete,
Any course of action on the basis of the assumed motives of the other person
is totally unacceptable. To say a person should make his motives known to
evade being depreciated by another person is ridiculous. Furthermore, allow
me to point out to you that an application for a ten inch screen of a
mini-laptop might need every bit of the screen and hence might need a
backdrop that covers the entire screen: so the issue is relative /
circumstantial. In general, the reason I would not sell an application that
changes the colour of the client’s display, is that I would find it impolite
to do so, and because if there were bugs, the display of the client might
end up in a terrible mess.

Zach.
 
Z

Zach Maslin

Peter Duniho said:
On 6/10/11 11:11 AM, Zach wrote:
p.s. The "high road" is generally considered a _good_ thing to take. You
seem to mean it otherwise, but if you want to criticize other people for
their behavior, you might as well get your idioms right. :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Come back to me again when English isn't your daily
language, but which you can speak apart from three
other languages. As far as I am concerned this remark
is more of the same. But thank you for drawing my attention
to the misuse of an expression!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top