Sign in to follow this  
Followers 0
Synapse

GUICtrlCreateCheckbox Question

8 posts in this topic

Hi...i was trying to do a GUI that had a dark background color...and unfortunately the text of the GUICtrlCreateCheckbox is almoust invisible... :)

Is there a way to give a specific color to GUICtrlCreateCheckbox ??? <_<

Thanks :P

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
GUICreate("", 260, 118, 211, 156)
GUISetBkColor(0x000000)
GUICtrlCreateCheckbox("This is a checkbox with background color", 24, 20, 221, 25)
GUICtrlSetBkColor(-1, 0xFFFF00);Background color for the checkbox
GUICtrlCreateCheckbox("This is checkbox with differet color font", 24, 64, 225, 23)
GUICtrlSetColor(-1, 0xFFFFFF);font color for the checkbox
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Download Koda, man.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
GUICreate("", 260, 118, 211, 156)
GUISetBkColor(0x000000)
GUICtrlCreateCheckbox("This is a checkbox with background color", 24, 20, 221, 25)
GUICtrlSetBkColor(-1, 0xFFFF00);Background color for the checkbox
GUICtrlCreateCheckbox("This is checkbox with differet color font", 24, 64, 225, 23)
GUICtrlSetColor(-1, 0xFFFFFF);font color for the checkbox
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Download Koda, man.

Dude i have Koda...and i didn`t asked how to change the background color of the checkboxes text...i asked if it`s possible to change the text`s color...cuz it`s fixed on the black color...BTW thx 4 the reply

Share this post


Link to post
Share on other sites

Dude i have Koda...and i didn`t asked how to change the background color of the checkboxes text...i asked if it`s possible to change the text`s color...cuz it`s fixed on the black color...BTW thx 4 the reply

OH Sorry, I was just giving you two possibilites. Both of them might solve your problem, you didn't specify that in your question so there's no need to be rude.

Is there a way to give a specific color to GUICtrlCreateCheckbox ???

GUICtrlSetColor()

Share this post


Link to post
Share on other sites

OH Sorry, I was just giving you two possibilites. Both of them might solve your problem, you didn't specify that in your question so there's no need to be rude.

GUICtrlSetColor()

Sorry I didn`t want 2 be rude...sorry again...and I apreciate ypur replays....but I allready used that function...and it`s not working....The checkbox keeps whatever I do it`s black color <_<

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Problem is that windows theme override color setting for checkbox text, so you won't see any change after GUICtrlSetColor() unless you're running on Classic theme...

So the easiest way is to set Classic for that control...

#include <GUIConstantsEx.au3>

Global $CB_Text_Color = 0x0000FF

$hGui = GUICreate("Checkbox Text color", 300,100)
GUISetBkColor(0xff0000, $hGui)
$check1 = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 250, 20)
GUICtrlSetColor(-1, $CB_Text_Color)
GuiCtrlSetTheme(-1, 0)
$check2 = GUICtrlCreateCheckbox("CHECKBOX 2", 10, 50, 250, 20)
GUICtrlSetColor(-1, $CB_Text_Color)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
Wend

;Theming:
;$fShow = 0 to turn off
;$fShow = 1 to turn on
Func GuiCtrlSetTheme($cID, $fShow = 0)
    If $fShow Then
        DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($cID), "int", 0, "int", 0)
    Else
        DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($cID), "wstr", " ", "wstr", " ")
    EndIf
EndFunc

I've also experimented with WM_CTLCOLORSTATIC to no good result, maybe it needs ownerdrawing to work properly. In any case, that would require substantially more code.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Here is one, its in Autoit Wrapperrs

#include <GUIConstants.au3>
Dim $XS_n

GUICreate("My GUI Checkbox")  ; will create a dialog box that when displayed is centered
GUISetBkColor(0x000000)
If XPStyle(1) Then MsgBox(0,0,"on", 2)
$checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 15)
GUICtrlSetColor($checkCN, 0xFF0000)
GUICtrlSetBkColor($checkCN, 0x000000);0xFFFFFF)
If XPStyle(0) Then MsgBox(0,0,"off", 2)
GUISetState()       ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func XPStyle($OnOff = 1)   
    If $OnOff And StringInStr(@OSTYPE, "WIN32_NT") Then
        $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return 1
    ElseIf StringInStr(@OSTYPE, "WIN32_NT") And IsArray($XS_n) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
        $XS_n = ""
        Return 1
    EndIf
    Return 0
EndFunc   ;==>XPStyle

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thx a lot... <_<

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0