jayinoz Posted December 18, 2023 Share Posted December 18, 2023 Hi folks, I'm trying to draw 5 circles/ My code draw's 4 I don't understand what GUICtrlCreateGraphic does exactly. Why do I need both it, and GUICtrlSetGraphic, and why do both have co-ordinates? How can I get my missing circle. Thanks as always #include <GUIConstantsEx.au3> #include <ColorConstants.au3> GUICreate("My Draw", 300, 300) $NumCircles = 5 Local $circles[$NumCircles] $size = 10 $xPos = 20 $yPos = 50 $Colour = "0x21FA06" GUISetState(@SW_SHOW) For $ThisCircle = 0 to $NumCircles - 1 ConsoleWrite("Drawing circle number " & $ThisCircle & @CRLF) sleep (1000) $circles[$ThisCircle] = GUICtrlCreateGraphic(0, 0, 300, 300) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Colour, $Colour) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $xPos + (($ThisCircle + 1) * $size * 1.3), $yPos, $size, $size) Next sleep(1000) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;********************************** Link to comment Share on other sites More sharing options...
Developers Jos Posted December 18, 2023 Developers Share Posted December 18, 2023 Your code draws 5 green circles for me. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jayinoz Posted December 18, 2023 Author Share Posted December 18, 2023 This is what I get... Link to comment Share on other sites More sharing options...
Developers Jos Posted December 18, 2023 Developers Share Posted December 18, 2023 (edited) So which one isn't drawn for you? First/last? What happens when you create none overlapping graphics like this?: For $ThisCircle = 0 to $NumCircles - 1 ConsoleWrite("Drawing circle number " & $ThisCircle & @CRLF) sleep (1000) $circles[$ThisCircle] = GUICtrlCreateGraphic($xPos + (($ThisCircle + 1) * $size * 1.3), $ypos, 12, 12) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Colour, $Colour) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 1, 1, $size, $size) Next Edited December 18, 2023 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jayinoz Posted December 18, 2023 Author Share Posted December 18, 2023 Hi Jos, It's the first circle that is not appearing in my code. When I change it for your code no circles appear. Thanks Link to comment Share on other sites More sharing options...
Nine Posted December 18, 2023 Share Posted December 18, 2023 (edited) I also ran your code and like Jos, it displayed the 5 circles, but I thought that you shouldn't have to create multiple graphics. So I made this : #include <GUIConstantsEx.au3> #include <ColorConstants.au3> GUICreate("My Draw", 300, 300) $NumCircles = 5 $size = 10 $xPos = 20 $yPos = 50 $Colour = "0x21FA06" GUISetState(@SW_SHOW) $circle = GUICtrlCreateGraphic(0, 0, 300, 300) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Colour, $Colour) For $ThisCircle = 0 to 4 GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $xPos + (($ThisCircle + 1) * $size * 1.3), $yPos, $size, $size) Sleep(500) ConsoleWrite($ThisCircle & @CRLF) Next sleep(1000) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;********************************** And oddly only one is appearing. But if I comment out the sleep line in the loop, it all appears correctly. That smells like a bug to me... ps. not that it really matters, but it is the last circle that is not showing (based on the screen capture that you added) Edited December 18, 2023 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Andreik Posted December 18, 2023 Share Posted December 18, 2023 @Nine Same result here. This looks like a bug and require further investigations. If you haven't already, please open a ticket so it could be fixed. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
ioa747 Posted December 18, 2023 Share Posted December 18, 2023 #include <GUIConstantsEx.au3> #include <ColorConstants.au3> GUICreate("My Draw", 300, 300) $NumCircles = 5 $size = 10 $xPos = 20 $yPos = 50 $Colour = "0x21FA06" GUISetState(@SW_SHOW) $circle = GUICtrlCreateGraphic(0, 0, 300, 300) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Colour, $Colour) For $ThisCircle = 0 to 4 GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $xPos + (($ThisCircle + 1) * $size * 1.3), $yPos, $size, $size) GUICtrlSetGraphic(-1, $GUI_GR_REFRESH) ConsoleWrite($ThisCircle & @CRLF) Sleep(500) Next ;~ sleep(1000) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;********************************** robertocm 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Nine Posted December 18, 2023 Share Posted December 18, 2023 Yep, it is doing the trick... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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