Function Reference


GUICtrlSetPos

Changes the position of a control within the GUI window.

GUICtrlSetPos ( controlID, left [, top [, width [, height]]] )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
left The left side of the control.
top [optional] The top of the control.
width [optional] The width of the control.
height [optional] The height of the control .

Return Value

Success: 1.
Failure: 0.

Remarks

If the Default keyword is used as a parameter, the current value is not modified.

Related

GUICtrlCreate...

Example

Example 1

#include <GUIConstantsEx.au3>

Example()

Func Example()

        GUICreate("My GUI position") ; will create a dialog box that when displayed is centered

        GUISetFont(16)
        Local $idLabel = GUICtrlCreateLabel("my moving label", 10, 20)

        GUISetState(@SW_SHOW)

        Local $idMsg, $bToggle = False
        While 1
                $idMsg = GUIGetMsg()

                If $idMsg = $GUI_EVENT_CLOSE Then Exit
                $bToggle = Not $bToggle
                If $bToggle Then
                        GUICtrlSetPos($idLabel, 20, 20)
                Else
                        GUICtrlSetPos($idLabel, 20, 30)
                EndIf
                Sleep(160)
        WEnd
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
        Local $iOldOpt = Opt("GUICoordMode", 1)

        Local $hGUI = GUICreate("My GUI icon Race", 350, 74, -1, -1)
        GUICtrlCreateLabel("", 331, 0, 1, 74, 5)
        Local $idIcon1 = GUICtrlCreateIcon(@ScriptDir & '\Extras\dinosaur.ani', -1, 0, 0, 32, 32)
        Local $idIcon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 0, 40, 32, 32)

        GUISetState(@SW_SHOW)

        Local $a = 0, $b = 0
        While ($a < 300) And ($b < 300)
                $a += Random(0, 1, 1)
                $b += Random(0, 1, 1)
                GUICtrlSetPos($idIcon1, $a, 0)
                GUICtrlSetPos($idIcon2, $b, 40)
                Sleep(10)
        WEnd
        Opt("GUICoordMode", $iOldOpt)
        If $a > $b Then
                MsgBox($MB_SYSTEMMODAL, 'Race results', 'The dinosaur won', 0, $hGUI)
        Else
                MsgBox($MB_SYSTEMMODAL, 'Race results', 'The horse won', 0, $hGUI)
        EndIf
EndFunc   ;==>Example