Page 1 of 1
Colorizing CheckBoxes in XP...
Posted: Sat Aug 13, 2005 9:44 pm
by HeX0R
The following example works perfectly BUT:
As soon as you activate WinXP Style on your pc and activate the compiler option xp-skin the fontcolor will be black
(well i guess it depends on the used winxp style, but at least it won't be the wished white color).
Any ideas ?
This only happens to checkboxes btw...
Code: Select all
OpenWindow(0,100,150,120,40,#PB_Window_SystemMenu,"")
Brush = CreateSolidBrush_($808080)
Procedure myCallback(WindowID, Message, wParam, lParam)
Shared Brush
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_CTLCOLORSTATIC
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = Brush
EndSelect
ProcedureReturn Result
EndProcedure
SetWindowCallback(@myCallback())
CreateGadgetList(WindowID())
CheckBoxGadget(4, 10, 10,100, 20, "Test")
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
Posted: Tue Aug 16, 2005 10:15 am
by HeX0R
Anyone ?
Where is our Windoze-Guru Sparkie these days ? On Holiday i guess

Posted: Mon Aug 29, 2005 1:26 am
by Sparkie
Hi HeX0R
Not sure what's causing the problem but here's a quick "hack" if you can live with it for now. I'll take a closer look when I get a chance.
This disables the XP Theme for the OptionGadget and allows the color changes.
Code: Select all
OpenWindow(0,100,150,120,40,#PB_Window_SystemMenu,"")
Brush = CreateSolidBrush_($808080)
Procedure myCallback(WindowID, Message, wParam, lParam)
Shared Brush
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_CTLCOLORSTATIC
Debug "HI"
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = Brush
EndSelect
ProcedureReturn Result
EndProcedure
SetWindowCallback(@myCallback())
CreateGadgetList(WindowID())
CheckBoxGadget(4, 10, 10,100, 20, "Test")
;--> Disable XP Theme for the OptionGadget
If OSVersion() = #PB_OS_Windows_XP
OpenLibrary(0, "uxtheme.dll")
CallFunction(0, "SetWindowTheme", GadgetID(4), @" ", @" ")
CloseLibrary(0)
EndIf
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
Posted: Mon Aug 29, 2005 1:48 am
by MrMat
Code: Select all
CallFunction(0, "SetWindowTheme", GadgetID(4), @" ", @" ")
That can randomly fail because the last two parameters should be pointers to null-terminated 16-bit unicode strings. Credit for tracking that down goes to Fred who helped fix a similar bug in my program

I think this is the simplest fix:
Code: Select all
CallFunction(0, "SetWindowTheme", GadgetID(4), @null.w, @null.w)
Posted: Mon Aug 29, 2005 1:56 am
by Sparkie
Thanks for the info MrMat
I'd go with Fred's recommendation in this case as well.

Posted: Mon Aug 29, 2005 2:06 am
by MrMat
No problem. I think Fred's suggestion was to label a Data.w 0 and reference that but @null.w should do the same thing (since it's a pointer to a 16-bit zero) and it saves typing a few characters...

Posted: Mon Aug 29, 2005 2:41 pm
by HeX0R
Haa, i knew you're the man!
Thanks a lot both of you, i surely can live with this "Hack".
Posted: Mon Aug 29, 2005 7:43 pm
by utopiomania
As soon as you activate WinXP Style on your pc and activate the compiler option xp-skin the fontcolor will be black
Will it still turn to black if
I don't acvtivate the option xp-skin in the compiler, and the user
activates WinXP Style on his PC?

Posted: Tue Aug 30, 2005 5:41 am
by HeX0R
Nope!
Only if both is activated
Posted: Tue Aug 30, 2005 1:30 pm
by localmotion34
isnt a checkbox a BUTTON? hence the #wm_colorstatic message wont be processed? doesnt the checkbox then nees to be ownerdrawn, and the Bkcolor set to "coloref" whatever?