Jump to content

GUICtrlSetDefColor After Controls Created


jercfd
 Share

Recommended Posts

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.

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