Jump to content

GUICtrlCreateCheckbox + GUICtrlSetColor.


Info
 Share

Recommended Posts

GUICtrlCreateCheckbox ("Lol", 50, 40, 100, 20)
GUICtrlSetColor(-1, 0xFFFFFF)

My background color is black, so I wanted to change the CheckBox'es text color to white.

Doesn't work.

Help?

Edited by Info
Link to comment
Share on other sites

GUICtrlCreateCheckbox ("Lol", 50, 40, 100, 20)
GUICtrlSetColor(-1, 0xFFFFFF)

My background color is black, so I wanted to change the CheckBox'es text color to white.

Doesn't work.

Help?

Try this trick

#include <GuiConstants.au3>

$GUI = GUICreate("Test Script", 200, 100)
GUISetBkColor(0x000000, $GUI)

GUICtrlCreateLabel("LOL", 68, 42, 50, 17)
GUICtrlSetColor(-1, 0xFFFFFF)

GUICtrlCreateCheckbox ("", 50, 40, 14, 15)

GUISetState(@SW_SHOW, $GUI)

Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

:)

Link to comment
Share on other sites

What version of Windows are you using? I looked in the AutoIt Help file under "GUICtrlSetColor" and found this caveat:

Checkbox, Radio or Progress controls cannot be painted if the "Windows XP style" is used.

Button controls are always painted in "Windows Classic style".

Code-wise, checkboxes are actually buttons having a special style to them.

I don't know which syle you might need to use for your GUI window to get white text for those checkboxes.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

Try this trick

#include <GuiConstants.au3>

$GUI = GUICreate("Test Script", 200, 100)
GUISetBkColor(0x000000, $GUI)

GUICtrlCreateLabel("LOL", 68, 42, 50, 17)
GUICtrlSetColor(-1, 0xFFFFFF)

GUICtrlCreateCheckbox ("", 50, 40, 14, 15)

GUISetState(@SW_SHOW, $GUI)

Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

:)

That sucks =[

What version of Windows are you using? I looked in the AutoIt Help file under "GUICtrlSetColor" and found this caveat:

Code-wise, checkboxes are actually buttons having a special style to them.

I don't know which syle you might need to use for your GUI window to get white text for those checkboxes.

You right, I switched the style to classic and it worked.

I'll check if it works as an .exe file in WinXP style.

EDIT:

Not working, too bad for me.

I guess I'll have to use rasim's trick... =[

Edited by Info
Link to comment
Share on other sites

I thought of rasim's technique just about the time he posted it. I haven't tested his code but can guarantee that the workaround is typical of what we have to do in AutoIt sometimes. But this one isn't even radical in the least, there is no trickery involved - the saints while not smiling on it, would not condemn it. Perfectly legal.

Das Häschen benutzt Radar

Link to comment
Share on other sites

Info

That sucks =[

:) Thank you for good words.

Try this:

#include <GuiConstants.au3>

$GUI = GUICreate("Test Script", 200, 100)
GUISetBkColor(0x000000, $GUI)

$hCheckBox = GUICtrlCreateCheckbox ("Lol", 50, 40, 50, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hCheckBox), "wstr", "", "wstr", "")

GUISetState(@SW_SHOW, $GUI)

Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

:)

Link to comment
Share on other sites

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

The uses above actually change the XP settings, however this little UDF will do what you need and replace the users original settings

#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

MSCreator knows this one too!!..??

... there are more helpful snippets in Autoit Wrappers

8)

NEWHeader1.png

Link to comment
Share on other sites

MSCreator knows this one too!!..??

Yes sure, i pulled out from this example the line with DllCall :)

Btw, i do not like much the idea of using Global declaration here, maybe this function should return the old theme value?

Like this:

#include <GUIConstants.au3>

GUICreate("_SetThemeAppProperties Example", 200, 100)  ; will create a dialog box that when displayed is centered
GUISetBkColor(0x000000)

$iOld_AppTheme = _SetThemeAppProperties(0)

$CheckBox = GUICtrlCreateCheckbox("CHECKBOX", 60, 40, 120, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)

_SetThemeAppProperties($iOld_AppTheme)


GUISetState() ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func _SetThemeAppProperties($iTheme=0)
    If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
    
    Local $a_Old_AppTheme = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
    If @error Then Return 0
    
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $iTheme)
    If @error Then Return 0
    
    Return $a_Old_AppTheme[0]
EndFunc   ;==>SetThemeAppProperties

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...