GetSysColor / SetSysColors

  • Thread starter Thread starter Ian Williamson
  • Start date Start date
I

Ian Williamson

Does anyone know if these can be P/Invoked on a CE.NET
4.1 device? If so, which library are they in?

Thanks, Ian
 
Almost everything in the API is in coredll.dll. That's the case here, too.

Paul T.
 
That is the library I have been referring too, but it
does not seem to have any effect, even when SetSysColors
returns true.

[DllImport("coredll.dll")]
private static extern Int32 GetSysColor(Int32 nIndex);

[DllImport("coredll.dll")]
private static extern Boolean SetSysColors(int cElements,
Int32[] lpaElements, Int32[] lpaRgbValues);

private const int COLOR_ACTIVECAPTION = 19; //menu
background

public void ChangeColor()
{
int[] element = new int[] {COLOR_ACTIVECAPTION};
int[] rgb = new int[] {Color.Red.ToArgb() & 0x00FFFFFF};
bool b = SetSysColors(1, element, rgb);
}
 
I'm not sure, but I bellieve that change in system colors requires soft
reset

Ian Williamson said:
That is the library I have been referring too, but it
does not seem to have any effect, even when SetSysColors
returns true.

[DllImport("coredll.dll")]
private static extern Int32 GetSysColor(Int32 nIndex);

[DllImport("coredll.dll")]
private static extern Boolean SetSysColors(int cElements,
Int32[] lpaElements, Int32[] lpaRgbValues);

private const int COLOR_ACTIVECAPTION = 19; //menu
background

public void ChangeColor()
{
int[] element = new int[] {COLOR_ACTIVECAPTION};
int[] rgb = new int[] {Color.Red.ToArgb() & 0x00FFFFFF};
bool b = SetSysColors(1, element, rgb);
}

-----Original Message-----
Almost everything in the API is in coredll.dll. That's the case here, too.

Paul T.




.
 
Your declaration of COLOR_ACTIVECAPTION is way off the mark. If you look at
winuser.h in the PPC SDK or somewhere for COLOR_ACTIVECAPTION, you'll find
that it's

( 2 | SYS_COLOR_INDEX_FLAG)

and SYS_COLOR_INDEX_FLAG is 0x40000000.

If you make that change, it works as expected, except that
COLOR_ACTIVECAPTION is *not* the menu background color; it's the color of
the title bar for windows when they are the active window. I think that you
may want COLOR_MENU, instead, although I haven't tried that.

Paul T.

Ian Williamson said:
That is the library I have been referring too, but it
does not seem to have any effect, even when SetSysColors
returns true.

[DllImport("coredll.dll")]
private static extern Int32 GetSysColor(Int32 nIndex);

[DllImport("coredll.dll")]
private static extern Boolean SetSysColors(int cElements,
Int32[] lpaElements, Int32[] lpaRgbValues);

private const int COLOR_ACTIVECAPTION = 19; //menu
background

public void ChangeColor()
{
int[] element = new int[] {COLOR_ACTIVECAPTION};
int[] rgb = new int[] {Color.Red.ToArgb() & 0x00FFFFFF};
bool b = SetSysColors(1, element, rgb);
}

-----Original Message-----
Almost everything in the API is in coredll.dll. That's the case here, too.

Paul T.




.
 
You can use the SystemColors class to get values of system colors. In this
case, you would not need to p/invoke.

Hope this helps,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Ian Williamson" <[email protected]>
| Sender: "Ian Williamson" <[email protected]>
| Subject: GetSysColor / SetSysColors
| Date: Fri, 14 Nov 2003 12:29:52 -0800
| Lines: 6
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOq7g6jA/iUMmU9RBakbif2cBTZzg==
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:38663
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Does anyone know if these can be P/Invoked on a CE.NET
| 4.1 device? If so, which library are they in?
|
| Thanks, Ian
|
|
|
 
Ahh, I was lazy and was assuming that the MSDN
documentation was providing a zero based index with
regards to the list of display elements.

As for COLOR_ACTIVECAPTION, it was simply a constant name
that I lifted from elsewhere and did not bother to change
it, hence why I included the comment so that you would
know that 19 referred to the menu background (well, if it
HAD been a zero based index).

Serge, I will look at your suggestion, but I am not sure
if it will work for what I am trying to do.

For those curious, I need to change the 3D Objects and
Dialog Background colors so that I can control the
ReadOnly background color of a TextBox. Thankfully, this
will be the only application running on the handheld
device, so I will not get unexpected/unwanted results
when these global color changes occur.

Thanks for all the help. Much appreciated.

Cheers, Ian

-----Original Message-----
Your declaration of COLOR_ACTIVECAPTION is way off the mark. If you look at
winuser.h in the PPC SDK or somewhere for
COLOR_ACTIVECAPTION, you'll find
that it's

( 2 | SYS_COLOR_INDEX_FLAG)

and SYS_COLOR_INDEX_FLAG is 0x40000000.

If you make that change, it works as expected, except that
COLOR_ACTIVECAPTION is *not* the menu background color; it's the color of
the title bar for windows when they are the active window. I think that you
may want COLOR_MENU, instead, although I haven't tried that.

Paul T.

That is the library I have been referring too, but it
does not seem to have any effect, even when SetSysColors
returns true.

[DllImport("coredll.dll")]
private static extern Int32 GetSysColor(Int32 nIndex);

[DllImport("coredll.dll")]
private static extern Boolean SetSysColors(int cElements,
Int32[] lpaElements, Int32[] lpaRgbValues);

private const int COLOR_ACTIVECAPTION = 19; //menu
background

public void ChangeColor()
{
int[] element = new int[] {COLOR_ACTIVECAPTION};
int[] rgb = new int[] {Color.Red.ToArgb() & 0x00FFFFFF};
bool b = SetSysColors(1, element, rgb);
}

-----Original Message-----
Almost everything in the API is in coredll.dll.
That's
the case here, too.
Paul T.

Does anyone know if these can be P/Invoked on a CE.NET
4.1 device? If so, which library are they in?

Thanks, Ian




.


.
 
Back
Top