Detect if Themes are enabled?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred Hedges

    #1

    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?


  • Fred Hedges

    #2
    Re: Detect if Themes are enabled?


    I solved this using the code below, I hope it's more or less correct:


    Dim myVersion As Version =
    OSFeature.Featu re.GetVersionPr esent(OSFeature .Themes)

    If not myVersion Is Nothing Then

    Return True

    Else

    Return False

    End If


    "Fred Hedges" <dontlike@spamm uch.com> escribió en el mensaje
    news:e4ccba$o9e $1$8300dec7@new s.demon.co.uk.. .[color=blue]
    > 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?
    >
    >[/color]


    Comment

    • Ken Tucker [MVP]

      #3
      Re: Detect if Themes are enabled?

      Fred,

      That is a good method.

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

      "Fred Hedges" wrote:
      [color=blue]
      >
      > I solved this using the code below, I hope it's more or less correct:
      >
      >
      > Dim myVersion As Version =
      > OSFeature.Featu re.GetVersionPr esent(OSFeature .Themes)
      >
      > If not myVersion Is Nothing Then
      >
      > Return True
      >
      > Else
      >
      > Return False
      >
      > End If
      >
      >
      > "Fred Hedges" <dontlike@spamm uch.com> escribió en el mensaje
      > news:e4ccba$o9e $1$8300dec7@new s.demon.co.uk.. .[color=green]
      > > 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?
      > >
      > >[/color]
      >
      >
      >[/color]

      Comment

      • Stanimir Stoyanov

        #4
        RE: Detect if Themes are enabled?

        Hi Fred,

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

        <System.Runtime .InteropService s.DllImport("Ux Theme")> _
        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.OSV ersion.Version >= New Version(5, 1) Then
        fThemesActive = IsThemeActive()
        End If

        --
        Stanimir Stoyanov
        www.stoyanoff.info


        "Fred Hedges" wrote:
        [color=blue]
        > 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?
        >
        >
        >[/color]

        Comment

        • Fred Hedges

          #5
          Re: Detect if Themes are enabled?

          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" <dontlike@spamm uch.com> escribió en el mensaje
          news:e4cdio$qgf $1$8300dec7@new s.demon.co.uk.. .[color=blue]
          >
          > I solved this using the code below, I hope it's more or less correct:
          >
          >
          > Dim myVersion As Version =
          > OSFeature.Featu re.GetVersionPr esent(OSFeature .Themes)
          >
          > If not myVersion Is Nothing Then
          >
          > Return True
          >
          > Else
          >
          > Return False
          >
          > End If
          >
          >
          > "Fred Hedges" <dontlike@spamm uch.com> escribió en el mensaje
          > news:e4ccba$o9e $1$8300dec7@new s.demon.co.uk.. .[color=green]
          >> 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?
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Fred Hedges

            #6
            Re: Detect if Themes are enabled?


            Thats the one! Thanks.

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






            "Stanimir Stoyanov" <admin{at}stoya noff{dot}info> escribió en el mensaje
            news:278C2F44-B487-4A31-94C8-3B845BB384DF@mi crosoft.com...[color=blue]
            > Hi Fred,
            >
            > You can use UxTheme's IsThemActive() API, available in Windows XP (NT 5.1)
            > and later.
            >
            > <System.Runtime .InteropService s.DllImport("Ux Theme")> _
            > 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.OSV ersion.Version >= New Version(5, 1) Then
            > fThemesActive = IsThemeActive()
            > End If
            >
            > --
            > Stanimir Stoyanov
            > www.stoyanoff.info
            >
            >
            > "Fred Hedges" wrote:
            >[color=green]
            >> 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?
            >>
            >>
            >>[/color][/color]


            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: Detect if Themes are enabled?

              "Fred Hedges" <dontlike@spamm uch.com> schrieb:[color=blue]
              > Public Declare Auto Function IsThemeActive Lib "uxtheme.dl l" () As Boolean[/color]

              Remove the 'Auto' keyword.

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

              Comment

              Working...