Jump to content

Recommended Posts

Posted

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
;**********************************

 

 

  • Developers
Posted (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 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.
  :)

Posted (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 by Nine
Posted

 

#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
;**********************************

 

I know that I know nothing

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...