Sign in to follow this  
Followers 0
jvanegmond

Moving Around Multiple Graphic Controls

4 posts in this topic

Look at this little test code i've built. It builds 2 squares and then moves them to the side. Looks ok to me, but watch what happens..

#include <GUIConstants.au3>

Dim $graphic[2][3]

GUICreate("test code", 600, 250, -1, -1, $WS_POPUP)
GUISetBkColor(0)

$graphic[0][0] = GUICtrlCreateGraphic(0, 0, 100, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 100, 100)

$graphic[1][0] = GUICtrlCreateGraphic(0, 150, 100, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 100, 100)

GUISetState()

Sleep(4000)

While 1
    $graphic[0][1] += 50
    GUICtrlSetPos($graphic[0][0], $graphic[0][1], $graphic[0][2])
    Sleep(100)
    
    $graphic[1][1] += 50
    GUICtrlSetPos($graphic[1][0], $graphic[1][1], $graphic[1][2])
    Sleep(100)
WEnd

Share this post


Link to post
Share on other sites



and you wanted this ?

#include <GUIConstants.au3>

Dim $graphic[2][3]

GUICreate("test code", 600, 250, -1, -1, $WS_POPUP)
GUISetBkColor(0)

$graphic[0][0] = GUICtrlCreateGraphic(0, 0, 100, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 100, 100)

$graphic[1][0] = GUICtrlCreateGraphic(0, 150, 100, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 100, 100)

GUISetState()

Sleep(4000)

While 1
    $graphic[0][1] += 50
    GUICtrlSetPos($graphic[0][0], $graphic[0][1], $graphic[0][2])
    Sleep(100)
    
    $graphic[1][1] += 50
    GUICtrlSetPos($graphic[1][0], $graphic[1][1], 150)
    Sleep(100)
WEnd

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That's Right.

[Edit] I got it. It's the problem that i left a few vars in the array undefined, so when it moves to position "" it gives a error and somehow manages to remove the entire control.

I've now just added $graphic[0][1] = $xcoord (pre defined in function)

and ofcourse also for $graphic[0][2] = $ycoord

Thanks for making me realise my mistake.

Edited by Manadar

Share this post


Link to post
Share on other sites

That's Right.

So you need to set the correct value for $graphic[0][2] and $graphic[1][2].

They are both zero so both squares are located at the same spot after the first move.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0