Determine color scheme used by app

G

Guest

I want to determine the Windows color scheme that is being used by my app.
This means that I need to determine the following:

1. Does the OS support themes?
2. Are themes currently enabled within the OS?
3. Are themes currently enabled within the application?
4. If all of the above are true, then what color scheme is being used (e.g.,
Default (blue), Olive Green or Silver if the OS is Windows XP)?

Also, I have not used Windows Vista so any help with the possible color
schemes with that OS would be greatly appreciated.

Thanks for any help!
Lance
 
A

Armin Zingler

ljlevend2 said:
I want to determine the Windows color scheme that is being used by
my app. This means that I need to determine the following:

1. Does the OS support themes?

System.Windows.Forms.VisualStyles.VisualStyleInformation.IsSupportedByOS

2. Are themes currently enabled within the OS?
System.Windows.Forms.VisualStyles.VisualStyleInformation.IsEnabledByUser

3. Are themes currently enabled within the application?
System.Windows.Forms.Application.VisualStyleState

4. If all of the above are true, then what color scheme is being used
(e.g.,
Default (blue), Olive Green or Silver if the OS is Windows XP)?
System.Windows.Forms.VisualStyles.VisualStyleInformation.ColorScheme


Also, I have not used Windows Vista so any help with the possible color
schemes with that OS would be greatly appreciated.

Can't help you with that.


Armin
 
J

Jialiang Ge [MSFT]

Hello, Lance

To supplement Armin's answer, I think we could refer to the MSDN article:
http://msdn2.microsoft.com/en-us/library/microsoft.windows.themes.themecolor
..aspx
for the possible color schemes.

#1. Homestead: Used by the Luna theme; the localized color name is Olive.
#2. Metallic: Used by the Luna theme; the localized color name is Sliver.
#3. NormalColor: Used by the Luna, Aero, and Classic themes; the localized
color name is Blue.

Thanks,
Jialiang Ge ([email protected], remove ¡®online.¡¯)
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box ¡°Tools/Options/Read: Get 300 headers at a time¡±
to see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided ¡°AS IS¡± with no warranties, and confers no
rights.
 
G

Guest

Wow, thank you both so much for the info. That was quick and a lot easier
than I expected.

Just one more question ... is there an event (or some other notification)
when the value of
System.Windows.Forms.VisualStyles.VisualStyleInformation.ColorScheme changes?
Of course I could just test the value during a timer's tick event, but I
wanted to see if there is a more efficient technique. I need to know when
VisualStyleInformation.ColorScheme changes so that I update my custom drawn
controls if the user changes the Windows Color Scheme while my app is running.

Thanks again!
Lance
 
A

Armin Zingler

ljlevend2 said:
Wow, thank you both so much for the info. That was quick and a lot
easier than I expected.

Just one more question ... is there an event (or some other
notification) when the value of
System.Windows.Forms.VisualStyles.VisualStyleInformation.ColorScheme
changes? Of course I could just test the value during a timer's tick
event, but I wanted to see if there is a more efficient technique.
I need to know when VisualStyleInformation.ColorScheme changes so
that I update my custom drawn controls if the user changes the
Windows Color Scheme while my app is running.

Thanks again!
Lance

Untested:
Subscribe to Microsoft.Win32.SystemEvents.UserPreferenceChanged. In the
handler check

If e.Category = Microsoft.Win32.UserPreferenceCategory.VisualStyle



Armin
 
J

Jialiang Ge [MSFT]

Hello Lance,

Armin's suggestion is right. UserPreferenceChanged event is able to capture
the change of system Theme. I did a test for it:

SystemEvents.UserPreferenceChanged += new
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);

void SystemEvents_UserPreferenceChanged(object sender,
UserPreferenceChangedEventArgs e)
{
if (e.Category == UserPreferenceCategory.VisualStyle)
{
MessageBox.Show("Changed");
}
}

Then when I change my system's theme from Windows Vista to Windows Classic,
the message box "Changed" is shown.

Thank you, Armin.

Lance, if you have any other concen or need anything else, please feel free
to let us know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

C-Services Holland b.v.

ljlevend2 schreef:
Wow, thank you both so much for the info. That was quick and a lot easier
than I expected.

Just one more question ... is there an event (or some other notification)
when the value of
System.Windows.Forms.VisualStyles.VisualStyleInformation.ColorScheme changes?
Of course I could just test the value during a timer's tick event, but I
wanted to see if there is a more efficient technique. I need to know when
VisualStyleInformation.ColorScheme changes so that I update my custom drawn
controls if the user changes the Windows Color Scheme while my app is running.

Thanks again!
Lance

What if the scheme is changed to another theme that the user downloaded?
 
J

Jialiang Ge [MSFT]

Hello Rinze,

I did a test on it. The event SystemEvents.UserPreferenceChanged is still
able to capture the change of theme.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hi Lance,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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