469,909 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

Detect if Themes are enabled?

Using .NET 1.1, I need to be able to detect if Themes are enabled or
disabled, not for a specific application, but for the system as a whole (ie.
the current user). The reason I need to be able to do this is because of
this bug in MFC http://support.microsoft.com/?kbid=319740, which is used to
build a component I am in turn making use of. So, I need to detect if
Themes are running and if so, see if the correct version of uxtheme.dll is
installed, else disallow a certain operation.

Any hints?
May 16 '06 #1
6 1812

I solved this using the code below, I hope it's more or less correct:
Dim myVersion As Version =
OSFeature.Feature.GetVersionPresent(OSFeature.Them es)

If not myVersion Is Nothing Then

Return True

Else

Return False

End If
"Fred Hedges" <do******@spammuch.com> escribió en el mensaje
news:e4*******************@news.demon.co.uk...
Using .NET 1.1, I need to be able to detect if Themes are enabled or
disabled, not for a specific application, but for the system as a whole
(ie. the current user). The reason I need to be able to do this is
because of this bug in MFC http://support.microsoft.com/?kbid=319740,
which is used to build a component I am in turn making use of. So, I need
to detect if Themes are running and if so, see if the correct version of
uxtheme.dll is installed, else disallow a certain operation.

Any hints?

May 16 '06 #2
Fred,

That is a good method.

Ken
-----------------

"Fred Hedges" wrote:

I solved this using the code below, I hope it's more or less correct:
Dim myVersion As Version =
OSFeature.Feature.GetVersionPresent(OSFeature.Them es)

If not myVersion Is Nothing Then

Return True

Else

Return False

End If
"Fred Hedges" <do******@spammuch.com> escribió en el mensaje
news:e4*******************@news.demon.co.uk...
Using .NET 1.1, I need to be able to detect if Themes are enabled or
disabled, not for a specific application, but for the system as a whole
(ie. the current user). The reason I need to be able to do this is
because of this bug in MFC http://support.microsoft.com/?kbid=319740,
which is used to build a component I am in turn making use of. So, I need
to detect if Themes are running and if so, see if the correct version of
uxtheme.dll is installed, else disallow a certain operation.

Any hints?


May 16 '06 #3
Hi Fred,

You can use UxTheme's IsThemActive() API, available in Windows XP (NT 5.1)
and later.

<System.Runtime.InteropServices.DllImport("UxTheme ")> _
Public Shared Function IsThemeActive() as Boolean
End Function

After the P/Invoke function is defined in the appropriate scope, you can
call it provided that the Operating System's version is at least Windows XP:

Dim fThemesActive As Boolean = False
If Environment.OSVersion.Version >= New Version(5, 1) Then
fThemesActive = IsThemeActive()
End If

--
Stanimir Stoyanov
www.stoyanoff.info
"Fred Hedges" wrote:
Using .NET 1.1, I need to be able to detect if Themes are enabled or
disabled, not for a specific application, but for the system as a whole (ie.
the current user). The reason I need to be able to do this is because of
this bug in MFC http://support.microsoft.com/?kbid=319740, which is used to
build a component I am in turn making use of. So, I need to detect if
Themes are running and if so, see if the correct version of uxtheme.dll is
installed, else disallow a certain operation.

Any hints?

May 16 '06 #4
To continue this conversation with myself, the above didn't work, because it
checks to see if the feature is present, not whether or not it is currently
switched on/off. I am still looking for a way to see if the user is using a
Theme (other than the stock "Classic Windows", which isn't really a Theme,
it's more the way things were before MS botched up it's themes
implementation).
"Fred Hedges" <do******@spammuch.com> escribió en el mensaje
news:e4*******************@news.demon.co.uk...

I solved this using the code below, I hope it's more or less correct:
Dim myVersion As Version =
OSFeature.Feature.GetVersionPresent(OSFeature.Them es)

If not myVersion Is Nothing Then

Return True

Else

Return False

End If
"Fred Hedges" <do******@spammuch.com> escribió en el mensaje
news:e4*******************@news.demon.co.uk...
Using .NET 1.1, I need to be able to detect if Themes are enabled or
disabled, not for a specific application, but for the system as a whole
(ie. the current user). The reason I need to be able to do this is
because of this bug in MFC http://support.microsoft.com/?kbid=319740,
which is used to build a component I am in turn making use of. So, I
need to detect if Themes are running and if so, see if the correct
version of uxtheme.dll is installed, else disallow a certain operation.

Any hints?


May 16 '06 #5

Thats the one! Thanks.

Public Declare Auto Function IsThemeActive Lib "uxtheme.dll" () As Boolean


"Stanimir Stoyanov" <admin{at}stoyanoff{dot}info> escribió en el mensaje
news:27**********************************@microsof t.com...
Hi Fred,

You can use UxTheme's IsThemActive() API, available in Windows XP (NT 5.1)
and later.

<System.Runtime.InteropServices.DllImport("UxTheme ")> _
Public Shared Function IsThemeActive() as Boolean
End Function

After the P/Invoke function is defined in the appropriate scope, you can
call it provided that the Operating System's version is at least Windows
XP:

Dim fThemesActive As Boolean = False
If Environment.OSVersion.Version >= New Version(5, 1) Then
fThemesActive = IsThemeActive()
End If

--
Stanimir Stoyanov
www.stoyanoff.info
"Fred Hedges" wrote:
Using .NET 1.1, I need to be able to detect if Themes are enabled or
disabled, not for a specific application, but for the system as a whole
(ie.
the current user). The reason I need to be able to do this is because of
this bug in MFC http://support.microsoft.com/?kbid=319740, which is used
to
build a component I am in turn making use of. So, I need to detect if
Themes are running and if so, see if the correct version of uxtheme.dll
is
installed, else disallow a certain operation.

Any hints?

May 16 '06 #6
"Fred Hedges" <do******@spammuch.com> schrieb:
Public Declare Auto Function IsThemeActive Lib "uxtheme.dll" () As Boolean


Remove the 'Auto' keyword.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Carl Mercier | last post: by
6 posts views Thread by NWx | last post: by
1 post views Thread by Dean Slindee | last post: by
6 posts views Thread by Clinton Farleigh | last post: by
reply views Thread by Don | last post: by
2 posts views Thread by CK | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.