Problem: Gui Botton verändern

  • Hallo,
    ich habe mal ein bischen mit dem Koda-Designer herumgespielt un bin dabei auf folgendes Problem gestoßen:
    Ich habe eine Gui mit einem Button und zwei Slidern (Höhe und Breite des Buttons). Nun möchte ich, dass wenn ich die Slider verschiebe sich jeweils die höhe und Breite des Button verändern.
    Dazu habe ich keinen Befehl gefunden(sowas, wie Change Button)
    Mein Skript sieht jetzt so aus:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hoehe=25
    $breite=57

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Test-Form", 322, 135, 190, 127)
    $Slider1 = GUICtrlCreateSlider(160, 8, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 50, 0)
    $Button1 = GUICtrlCreateButton("New Button", 208, 72, $breite, $Hoehe)
    $Slider2 = GUICtrlCreateSlider(160, 32, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 100, 0)
    $Label4 = GUICtrlCreateLabel("Höhe", 272, 8, 36, 17)
    $Label5 = GUICtrlCreateLabel("Breite", 272, 32, 36, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Slider1 And $Slider2
    If $nMsg = $button1 Then
    $Hoehe = GUICtrlRead($slider1)
    $Breite= GUICtrlRead($slider2)
    GUISetState(@SW_HIDE)
    $Form1 = GUICreate("Test-Form", 322, 135, 190, 127)
    $Slider1 = GUICtrlCreateSlider(160, 8, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 50, 10)
    $Button1 = GUICtrlCreateButton("New Button", 208, 72, $breite, $Hoehe)
    $Slider2 = GUICtrlCreateSlider(160, 32, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 100, 10)
    $Label4 = GUICtrlCreateLabel("Höhe", 272, 8, 36, 17)
    $Label5 = GUICtrlCreateLabel("Breite", 272, 32, 36, 17)
    GUISetState(@SW_SHOW)
    EndIf
    EndSwitch
    WEnd

    [/autoit]


    Wenn ich auf den Button klicke wird eine ganz neue Gui mit den Werten erstellt. Geht das auch anders?
    lg. Grünschnabel

  • GUICtrlSetPos()

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Test-Form", 322, 135, 190, 127)
    $Slider1 = GUICtrlCreateSlider(160, 8, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 50, 0)
    $Button1 = GUICtrlCreateButton("New Button", 208, 72, 57, 25)
    $Slider2 = GUICtrlCreateSlider(160, 32, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 100, 0)
    $Label4 = GUICtrlCreateLabel("Höhe", 272, 8, 36, 17)
    $Label5 = GUICtrlCreateLabel("Breite", 272, 32, 36, 17)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $hoehe = GUICtrlRead($Slider1)
    $breite = GUICtrlRead($Slider2)
    GUICtrlSetPos($Button1, 208, 72, $breite, $hoehe)
    EndSwitch
    WEnd

    [/autoit]
    • Offizieller Beitrag

    Beispiel:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    Global $xOld = 57, $yOld = 25
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Test-Form", 322, 135, 190, 127)
    $Slider1 = GUICtrlCreateSlider(160, 8, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 50, 0)
    GUICtrlSetData(-1, 25)
    $Button1 = GUICtrlCreateButton("Test Button", 18, 72, 60, 25)
    $Slider2 = GUICtrlCreateSlider(160, 32, 105, 17, $TBS_TOOLTIPS)
    GUICtrlSetLimit(-1, 150, 0)
    GUICtrlSetData(-1, 60)
    $Label4 = GUICtrlCreateLabel("Höhe", 272, 8, 36, 17)
    $Label5 = GUICtrlCreateLabel("Breite", 272, 32, 36, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    AdlibRegister("CheckSlider", 100)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $hoehe = GUICtrlRead($Slider1)
    $breite = GUICtrlRead($Slider2)
    GUICtrlSetPos($Button1, 18, 72, $breite, $hoehe)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func CheckSlider()
    Local $Width = GUICtrlRead($Slider2)
    Local $Hight = GUICtrlRead($Slider1)
    If $Width <> $yOld Or $Hight <> $xOld Then
    GUICtrlSetPos($Button1, 18, 72, $Width, $Hight)
    $yOld = $Width
    $xOld = $Hight
    EndIf
    EndFunc ;==>CheckSlider

    [/autoit]