taurus905 Posted June 11, 2006 Share Posted June 11, 2006 I was wondering if there is a way to change the background color of a gui and refresh or redraw the gui without having to exit the script and run it again. The following code is an example: ; Change Window Color.au3 #include <GUIConstants.au3> #include <Misc.au3> Dim $Menu_Window_Color $Window_Color = 0xffffff; White GUICreate( "Change Window Color", 400, 200, -1, -1, $WS_OVERLAPPEDWINDOW) GUISetBkColor( $Window_Color) GUICtrlCreateLabel( "Right-Click to see Menu.", 100, 50, 200, 18) _Create_Context_Menu(); Create Right-Click Menu GUISetState() While 1 $msg = GUIGetMsg() If $msg = $Menu_Window_Color Then _Change_Window_Color() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Exit Func _Create_Context_Menu(); Create Right-Click Menu $Menu_Window = GUICtrlCreateContextMenu() $Menu_Window_Color = GUICtrlCreateMenuitem("Color", $Menu_Window) EndFunc; --> _Create_Context_Menu Func _Change_Window_Color(); Change Window Color $New_Window_Color = _ChooseColor( 2, $Window_Color, 2) MsgBox( 0, "$New_Window_Color", $New_Window_Color) $Window_Color = $New_Window_Color ; ******** I Want to Refresh or Redraw Window here to show New Window Color. ******** EndFunc; --> _Change_Window_Color Thanks in advance for any help. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 11, 2006 Moderators Share Posted June 11, 2006 Like this?; Change Window Color.au3 #include <GUIConstants.au3> #include <Misc.au3> Dim $Menu_Window_Color $Window_Color = 0xffffff; White $Main = GUICreate( "Change Window Color", 400, 200, -1, -1, $WS_OVERLAPPEDWINDOW) GUISetBkColor( $Window_Color) GUICtrlCreateLabel( "Right-Click to see Menu.", 100, 50, 200, 18) _Create_Context_Menu(); Create Right-Click Menu GUISetState() While 1 $msg = GUIGetMsg() If $msg = $Menu_Window_Color Then GUISetBkColor(_Change_Window_Color(), $Main) EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Exit Func _Create_Context_Menu(); Create Right-Click Menu $Menu_Window = GUICtrlCreateContextMenu() $Menu_Window_Color = GUICtrlCreateMenuitem("Color", $Menu_Window) EndFunc; --> _Create_Context_Menu Func _Change_Window_Color(); Change Window Color $New_Window_Color = _ChooseColor( 2, $Window_Color, 2) MsgBox( 0, "$New_Window_Color", $New_Window_Color) $Window_Color = $New_Window_Color Return $Window_Color ; ******** I Want to Refresh or Redraw Window here to show New Window Color. ******** EndFunc; --> _Change_Window_Color AnonymousX 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
taurus905 Posted June 11, 2006 Author Share Posted June 11, 2006 (edited) Like this?Yes SmOke_N,Exactly like that. Thank you sir!taurus905Edited: SmOke_N, By editing those few lines, you showed me something so basic to AutoIt and programming in general. I appreciate you taking the time. I will use this technique in the future to make my life easier. Thank you for your quick response. Edited June 11, 2006 by taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs 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