Imbuter2000 Posted September 9, 2013 Share Posted September 9, 2013 I drawed a blue rectangle with this code: $border = GUICtrlCreateGraphic(0, 0, 500, 500) GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x0000FF) ; blue GUICtrlSetGraphic(-1, $GUI_GR_RECT, 5, 5, 495, 495) I want to change the color of this rectangle whenever an event occurs, however I tried to change it with another GUICtrlSetGraphic command or a GUICtrlSetColor without success. How am I supposed to change the color of it? Link to comment Share on other sites More sharing options...
Yashied Posted September 9, 2013 Share Posted September 9, 2013 GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x0000FF) ; blue GUICtrlSetGraphic($border, $GUI_GR_RECT, 5, 5, 495, 495) GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0xFF0000) ; red GUICtrlSetGraphic($border, $GUI_GR_RECT, 5, 5, 495, 495) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Wombat Posted September 10, 2013 Share Posted September 10, 2013 Here's a small example for you, don't just copy & paste, peruse the helpfile and study it: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ;START gUI $GUI1 = GUICreate("Rectangle Example", 448, 240, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose") $border = GUICtrlCreateGraphic(55, 16, 336, 145) GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0xFF0000) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) $Button1 = GUICtrlCreateButton("Green", 56, 192, 89, 33) GUICtrlSetOnEvent(-1, "TurnGreen") $Button2 = GUICtrlCreateButton("Blue", 176, 192, 89, 33) GUICtrlSetOnEvent(-1, "TurnBlue") $Button3 = GUICtrlCreateButton("Purple", 288, 192, 89, 33) GUICtrlSetOnEvent(-1, "TurnPurple") GUISetState(@SW_SHOW) ;END GUI While 1 WEnd Func GUIClose() Exit EndFunc ;==>GUIClose Func TurnGreen() GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0x00FF00) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) GUICtrlSetGraphic($border, $GUI_GR_REFRESH) EndFunc ;==>TurnGreen Func TurnBlue() GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0x0080FF) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) GUICtrlSetGraphic($border, $GUI_GR_REFRESH) EndFunc ;==>TurnBlue Func TurnPurple() GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0x8000FF) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) GUICtrlSetGraphic($border, $GUI_GR_REFRESH) EndFunc ;==>TurnPurple Also, you should put your code in autoit tags so that it will show like above... You should pay attention to this line of code: GUICtrlSetGraphic($border, $GUI_GR_REFRESH) it's very important. Imbuter2000 1 Just look at us.Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner The internet is our one and only hope at a truly free world, do not let them take it from us... Link to comment Share on other sites More sharing options...
Imbuter2000 Posted September 10, 2013 Author Share Posted September 10, 2013 Here's a small example for you, don't just copy & paste, peruse the helpfile and study it: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ;START gUI $GUI1 = GUICreate("Rectangle Example", 448, 240, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose") $border = GUICtrlCreateGraphic(55, 16, 336, 145) GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0xFF0000) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) $Button1 = GUICtrlCreateButton("Green", 56, 192, 89, 33) GUICtrlSetOnEvent(-1, "TurnGreen") $Button2 = GUICtrlCreateButton("Blue", 176, 192, 89, 33) GUICtrlSetOnEvent(-1, "TurnBlue") $Button3 = GUICtrlCreateButton("Purple", 288, 192, 89, 33) GUICtrlSetOnEvent(-1, "TurnPurple") GUISetState(@SW_SHOW) ;END GUI While 1 WEnd Func GUIClose() Exit EndFunc ;==>GUIClose Func TurnGreen() GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0x00FF00) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) GUICtrlSetGraphic($border, $GUI_GR_REFRESH) EndFunc ;==>TurnGreen Func TurnBlue() GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0x0080FF) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) GUICtrlSetGraphic($border, $GUI_GR_REFRESH) EndFunc ;==>TurnBlue Func TurnPurple() GUICtrlSetGraphic($border, $GUI_GR_COLOR, 0x00000, 0x8000FF) GUICtrlSetGraphic($border, $GUI_GR_RECT, 0, 0, 322, 126) GUICtrlSetGraphic($border, $GUI_GR_REFRESH) EndFunc ;==>TurnPurple Also, you should put your code in autoit tags so that it will show like above... You should pay attention to this line of code: GUICtrlSetGraphic($border, $GUI_GR_REFRESH) it's very important. Ahhh GUICtrlSetGraphic($border, $GUI_GR_REFRESH) was what I missed! Thanks Wombat!!! Link to comment Share on other sites More sharing options...
Wombat Posted September 11, 2013 Share Posted September 11, 2013 you may want to set the thread as answered then Just look at us.Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner The internet is our one and only hope at a truly free world, do not let them take it from us... 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