.Net - Detecting the Appearance Setting (Classic or XP?)

I have some UI in VB 2005 that looks great in XP Style, but goes hideous in Classic Style.

Any ideas about how to detect which mode the user is in and re-format the forms on the fly?

Post Answer Edit:

Thanks Daniel, looks like this will work. I'm using the first solution you posted with the GetCurrentThemeName() function.

I'm doing the following:

Function Declaration:

 Private Declare Unicode Function GetCurrentThemeName Lib "uxtheme" (ByVal stringThemeName As System.Text.StringBuilder, ByVal lengthThemeName As Integer, ByVal stringColorName As System.Text.StringBuilder, ByVal lengthColorName As Integer, ByVal stringSizeName As System.Text.StringBuilder, ByVal lengthSizeName As Integer) As Int32

Code Body:

Dim stringThemeName As New System.Text.StringBuilder(260)
Dim stringColorName As New System.Text.StringBuilder(260)
Dim stringSizeName As New System.Text.StringBuilder(260)

GetCurrentThemeName(stringThemeName, 260, stringColorName, 260, stringSizeName, 260) MsgBox(stringThemeName.ToString)

The MessageBox comes up Empty when i'm in Windows Classic Style/theme, and Comes up with "C:\WINDOWS\resources\Themes\luna\luna.msstyles" if it's in Windows XP style/theme. I'll have to do a little more checking to see what happens if the user sets another theme than these two, but shouldn't be a big issue.


Try using a combination of GetCurrentThemeName (MSDN Page) and DwmIsCompositionEnabled

I linked the first to PInvoke so you can just drop it in your code, and for the second one you can use the code provided in the MSDN comment:

[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();

See what results you get out of those two functions; they should be enough to determine when you want to use a different theme!

Need Your Help

Is it correct to use memory_order_relaxed at this code?

c++ c++11 concurrency atomic

Is it correct to use std::memory_order_relaxed at the following code?

Inefficient MySQL database/statements slowing PHP/JS system down

php mysql optimization

I have developed a fairly ramshackle PHP/JavaScript Reward system for my school's VLE.