IsThemeActive always returning true!!!???

Windows specific forum
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

IsThemeActive always returning true!!!???

Post by DoubleDutch »

Why does this code always return 1, even if xp skins are turned off?

Code: Select all

If OpenLibrary(0, "UxTheme.dll") 
  
  *f = IsFunction(0, "IsThemeActive") 
  
  If *f 
    Debug "Themes: " + Str(CallFunctionFast(*f)) 
  EndIf 
  
  CloseLibrary(0) 
EndIf 
Anyone have any ideas?

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Returns "0" for me when I go to
Control Panel > Performance and Maintenance > Adjust visual effects
and uncheck "Use visual styles on windows and buttons"

WinXPhome SP2
PB 3.93
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

I thought that if it was turned it off in the compiler settings, it would really be off.

Thanks for the info though :)

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

You're welcome DoubleDutch :)

I think the API GetThemeAppProperties is more suited to checking for a themed app. Just remember that your app's non-client area is always themed when using XP. The compiler setting Enable XP Skin Support is enabling you to use the theme (skin) on the gadgets. The Window (non-client area) is still being skined or "themed", regardless of the compiler setting. Just look at the Window Caption, it's appearance is the same whether XP skins is enabled or not. ;)

AKAIK, there are 2 ways to completely disable themes in your app...

1. Right click "yourapp.exe", choose Properties > Compatability and check Disable visual themes.

2. Use API GetThemeAppProperties and SetThemeAppProperties to remove #STAP_ALLOW_NONCLIENT and #STAP_ALLOW_CONTROLS

*Requires XP and UxTheme.dll

Code: Select all

#STAP_ALLOW_NONCLIENT = 1   ;(1 << 0)
#STAP_ALLOW_CONTROLS = 2    ;(1 << 1)
#STAP_ALLOW_WEBCONTENT = 4  ;(1 << 2)
#WM_THEMECHANGED = $31A
; --> Disable window and gadget themes (skin)
Procedure.s DisableThemes()
  If OpenLibrary(0, "UxTheme.dll") 
    *getTheme = IsFunction(0, "GetThemeAppProperties") 
    *setTheme = IsFunction(0, "SetThemeAppProperties") 
    theme = CallFunctionFast(*getTheme)
    CallFunctionFast(*setTheme, theme &~#STAP_ALLOW_NONCLIENT &~#STAP_ALLOW_CONTROLS)
    theme = CallFunctionFast(*getTheme)
    Select theme
      Case 0
        theme$ = "Non-client area and Gadgets are not able to be themed"
      Case 1
        theme$ = "Non-client is able to be themed"
      Case 2
        theme$ = "Gadgets are able to be themed"
      Case 3
        theme$ = "Non-client area and Gadgets are able to be themed"
    EndSelect
    SendMessage_(WindowID(), #WM_THEMECHANGED, 0, 0)
    CloseLibrary(0) 
  Else
    MessageRequester("Error", "UxTheme.dll not found")
    theme$ = ""
  EndIf 
  ProcedureReturn theme$
EndProcedure

If OpenWindow(0, 10, 10, 300, 200, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Disable Themes in XP") And CreateGadgetList(WindowID())
  theme$ = DisableThemes()
  If theme$
    ButtonGadget(0, 100, 90, 100, 20, "Theme info")
  EndIf
  Repeat 
    event = WaitWindowEvent() 
    If event = #PB_EventGadget And EventGadgetID() = 0
      MessageRequester("Theme info", theme$)
    EndIf
  Until event = #PB_Event_CloseWindow 
EndIf 
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Thanks for the code :D

I didn't notice the title being themed when skins are turned off - a bit of a giveaway really....

Doesn't a non-themed window when the rest are themed look wierd. I had forgotten what they looked like!

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

I like them, for admininstration tools, etc.. you dont need skins ;)
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Sparkie wrote:Just remember that your app's non-client area is always themed when using XP.
This is not entirely accurate. Many people disable the entire theme service from running in XP, which essentially turns it back into win2k. Just a heads up in case it affects your coding.
Post Reply