Sign in to follow this  
Followers 0
jercfd

GUICtrlSetDefColor After Controls Created

3 posts in this topic

How can I use GUICtrlSetDefColor to set the color of all my controls after the controls have been created. I tried to change the color after the controls are created but I still can't. I really don't want to use GUICtrlSetColor on each control because I have a lot of controls in multiple GUIs.

Share this post


Link to post
Share on other sites



How can I use GUICtrlSetDefColor to set the color of all my controls after the controls have been created. I tried to change the color after the controls are created but I still can't. I really don't want to use GUICtrlSetColor on each control because I have a lot of controls in multiple GUIs.

If you won't set the DefColor before you create the controls, then you can still use GuiCtrlSetColor without having to specify each control.

Just make your first and last controls dummy controls on each Gui and then run a loop to change the color:

GUICreate("test")
$StartCtrl = GUICtrlCreateDummy()
GUICtrlCreateLabel("Label", 5, 5)
GUICtrlCreateButton("Button", 5, 20, 50)
GUICtrlCreateEdit("Edit", 5, 50, 200, 100)
$EndCtrl = GUICtrlCreateDummy()

$btnChange = GUICtrlCreateButton("Change control colors", 25, 300)

GUISetState()
$ColorDef = True

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case - 3
            Exit
        Case $btnChange
            If $ColorDef Then
                $Color = 0xFF0000
            Else
                $Color = 0x000000
            EndIf
            For $i = $StartCtrl To $EndCtrl
                GUICtrlSetColor($i, $Color)
            Next
            $ColorDef = Not $ColorDef
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Thanks. It works great.

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