How to detect the style of user window?
-
Some XP user use the XP form style, some of them disable the style to use the classic one. However, this style really affect the look of my form. How can I know what is this setting in user computer?
You can P/Invoke
UxTheme.dll
which controls the window styles in XP like this...<DllImport("UxTheme.dll", _
CallingConvention:=CallingConvention.Winapi, _
CharSet:=CharSet.Auto)> _
Private Shared Function IsThemeActive() As Boolean
End FunctionIf this function returns true, the user is running a theme, if it returns false then the user is running 'Windows Classic Style' - no themes. Hope this helps :) Cheers, Will H
-
You can P/Invoke
UxTheme.dll
which controls the window styles in XP like this...<DllImport("UxTheme.dll", _
CallingConvention:=CallingConvention.Winapi, _
CharSet:=CharSet.Auto)> _
Private Shared Function IsThemeActive() As Boolean
End FunctionIf this function returns true, the user is running a theme, if it returns false then the user is running 'Windows Classic Style' - no themes. Hope this helps :) Cheers, Will H
-
Thank you so much and It is really a great hint for me, but it does not work by copy and paste. Where should I place it in my module ? Thank you~
To add it to a module you'll have to do two things... 1) Change the line
Private Shared Function IsThemeActive() As Boolean
to
Public Function IsThemeActive() As Boolean
(i.e. remove the word
Shared
and change the functions visibility toPublic
) 2) AddImports System.Runtime.InteropServices
to the top of your file. I havent done any VB.Net in a while so I hope that works :) Cheers, Will H