Funktionreferenz


GUICtrlSetPos

Beschreibung anzeigen in

Verändert die Position eines Controls innerhalb des GUI-Fensters.

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

Parameter

ControlID Die Identifikationsnummer des Controls (Control-ID), wie von einer GUICtrlCreate... Funktion zurückgegeben, oder -1 für das zuletzt erzeugte Control.
left Die linke Kante des Controls.
top [optional] Die Oberkante des Controls.
width [optional] Die Breite des Controls.
height [optional] Die Höhe des Controls.

Rückgabewert

Erfolg: 1.
Fehler: 0.

Bemerkungen

Falls das Default Schlüsselwort als Parameter verwendet wird, so wird der aktuelle Wert nicht verändert.

- - - - - - - - Erklärung der Controls - - - - - - - -

Verwandte Funktionen

GUICtrlCreate...

Beispiel

Beispiel 1

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("Meine GUI mit Positionsverschiebung eines Labels", 450) ; Erstellt ein GUI-Fenster welches mittig ausgerichtet wird

    GUISetFont(16)
    Local $idLabel = GUICtrlCreateLabel("Mein sich bewegendes 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(60)
    WEnd
EndFunc   ;==>Example

Beispiel 2

#include <MsgBoxConstants.au3>

Example()

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

    Local $hGui = GUICreate("Meine GUI: Iconrennen", 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, 'Rennergebnis', 'Der Dinosaurier hat gewonnen', 0, $hGui)
    Else
        MsgBox($MB_SYSTEMMODAL, 'Rennergebnis', 'Das Pferd hat gewonnen', 0, $hGui)
    EndIf
EndFunc   ;==>Example