Page 1 of 1

IsThemeActive always returning true!!!???

Posted: Sat Apr 23, 2005 3:16 pm
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

Posted: Tue Apr 26, 2005 10:41 pm
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

Posted: Wed Apr 27, 2005 1:53 am
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

Posted: Wed Apr 27, 2005 2:48 pm
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

Posted: Thu Apr 28, 2005 2:14 pm
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

Posted: Sun May 15, 2005 5:32 am
by dagcrack
I like them, for admininstration tools, etc.. you dont need skins ;)

Posted: Sun May 15, 2005 7:04 am
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.