Screen Color

Discussion in 'Microsoft C# .NET' started by Zach, Jun 10, 2011.

  1. Zach

    Zach Guest

    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);
    }
    }
    }
     
    Zach, Jun 10, 2011
    #1
    1. Advertisements

  2. Zach

    Zach Guest

    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" <> wrote in message
    news:4df21944$0$30714$...
    > 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);
    > }
    > }
    > }
     
    Zach, Jun 10, 2011
    #2
    1. Advertisements

  3. Zach

    Jeff Gaines Guest

    On 10/06/2011 in message <4df21944$0$30714$> 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
     
    Jeff Gaines, Jun 10, 2011
    #3
  4. Zach

    Zach Guest

    "Jeff Gaines" <> wrote in message
    news:...
    > On 10/06/2011 in message <4df21944$0$30714$> 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?
     
    Zach, Jun 10, 2011
    #4
  5. Zach

    Lee J. Moore Guest

    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
     
    Lee J. Moore, Jun 10, 2011
    #5
  6. Zach

    Lee J. Moore Guest

    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/library/ms724940(v=vs.85).aspx

    --
    Lee J. Moore
    Cheshire, UK

    "He who knows, does not speak. He who speaks, does not know." - Lao Tzu
     
    Lee J. Moore, Jun 10, 2011
    #6
  7. Zach

    Jeff Johnson Guest

    "Zach" <> wrote in message
    news:4df21944$0$30714$...

    > 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.
     
    Jeff Johnson, Jun 10, 2011
    #7
  8. Zach

    Zach Guest

    "Lee J. Moore" <> wrote in message
    news:ist9k2$5i2$...
    > 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/library/ms724940(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.
     
    Zach, Jun 10, 2011
    #8
  9. Zach

    Zach Guest

    "Jeff Johnson" <> wrote in message
    news:ist9k3$7h1$...
    > "Zach" <> wrote in message
    > news:4df21944$0$30714$...
    >
    >> 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.
     
    Zach, Jun 10, 2011
    #9
  10. Zach

    Zach Guest

    "Peter Duniho" <> wrote in message
    news:...
    > 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.
     
    Zach, Jun 10, 2011
    #10
  11. Zach

    Zach Guest

    "rossum" <> wrote in message
    news:...
    > On Fri, 10 Jun 2011 17:16:21 +0200, "Zach" <> wrote:
    >
    >>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.
     
    Zach, Jun 10, 2011
    #11
  12. Zach

    Zach Maslin Guest

    "Peter Duniho" <> wrote in message
    news:...
    > On 6/10/11 11:11 AM, Zach wrote:
    >> 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.

    >
    > 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.
     
    Zach Maslin, Jun 11, 2011
    #12
  13. Zach

    Zach Maslin Guest

    "Peter Duniho" <> wrote in message
    news:...
    > 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!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    Zach Maslin, Jun 11, 2011
    #13
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mohammad

    save a high color Image as 256 color or fewer.

    Mohammad, Sep 22, 2003, in forum: Microsoft C# .NET
    Replies:
    2
    Views:
    476
  2. pixel

    GDI color vs GDI+ color

    pixel, Jul 27, 2004, in forum: Microsoft C# .NET
    Replies:
    4
    Views:
    641
    pixel
    Jul 27, 2004
  3. Guest
    Replies:
    1
    Views:
    1,026
    Dmitriy Lapshin [C# / .NET MVP]
    Dec 20, 2004
  4. Sami
    Replies:
    4
    Views:
    221
    =?ISO-8859-2?Q?Marcin_Grz=EAbski?=
    Jan 27, 2005
  5. Guest
    Replies:
    7
    Views:
    212
Loading...

Share This Page