JohnOne Posted November 11, 2010 Share Posted November 11, 2010 (edited) I've dynamically changed the colour of a button upon click. My problem is, how to change it back, I have searched the help without luck getting the colour, or changing it back. I seen that you can set the default colour, but thats no good to me I dont think. So I tried GUICrtlSetStyle(), and the button returned to its previous colour, except it then disappears when you try to use it again. Im more than likely missing something. My question is what am I missing here? #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate('') $b1 = GUICtrlCreateButton("button1",10,10) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $b1 GUICtrlSetBkColor($b1,0x059122) Sleep(2000) GUICtrlSetStyle($b1,$GUI_SS_DEFAULT_GUI ) EndSelect WEnd Edited November 11, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
BugFix Posted November 11, 2010 Share Posted November 11, 2010 Do it so: #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate('') $b1 = GUICtrlCreateButton("button1",10,10,60) GUICtrlSetBkColor(-1, 0xFFFF00) GUISetState() $changed = False While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $b1 $changed = Not $changed If $changed Then GUICtrlSetBkColor($b1,0x059122) Else GUICtrlSetBkColor($b1, 0xFFFF00) EndIf EndSelect WEnd Best Regards BugFix Link to comment Share on other sites More sharing options...
Michiel78 Posted November 11, 2010 Share Posted November 11, 2010 (edited) You might also do it this way, so that the button changes back to the default color (you don't have to use a new bkcolor): #include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> GUICreate('') $b1 = GUICtrlCreateButton("button1",10,10) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $b1 GUICtrlSetBkColor($b1,0x059122) Sleep(2000) _GUICtrlButton_SetStyle($b1, $GUI_SS_DEFAULT_GUI) EndSelect WEnd Edited November 11, 2010 by Michiel78 Link to comment Share on other sites More sharing options...
JohnOne Posted November 11, 2010 Author Share Posted November 11, 2010 (edited) Thanks for the suggestion BugFix, except the point is to have the button return to its default themed colouring (which isnt a single colour) EDIT: Great, that next one worked Edited November 11, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted November 11, 2010 Author Share Posted November 11, 2010 Cheers Michiel78 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Michiel78 Posted November 11, 2010 Share Posted November 11, 2010 Cheers Michiel78You're welcome! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now