Problem mit Gui in einer Gui

  • Also hallo erst mal ich bin neu hier...
    ich habe eine Frage und zwar ich habe ein au3 skript mit 2 Formen drin

    Spoiler anzeigen

    #include
    #include
    #include
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 226, 92, 192, 124)
    $Button1 = GUICtrlCreateButton("öffne Form2", 0, 8, 225, 81, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    Case $Button1
    #include
    #include
    #include
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 223, 74, 193, 129)
    $Button1 = GUICtrlCreateButton("schliesse Form2", 0, 8, 217, 65, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUIDelete ()
    EndSwitch
    WEnd

    EndSwitch
    WEnd

    wenn ich jetzt auf "öffne Form2" klicke öffnet sich form2 (ist ja logisch...)
    wenn ich auf schließe Form2 gehe in der neu geöffneten gui geht die Form durchen Befehl
    guidelete ()
    natürlich zu....
    Meine Frage:
    Wenn ich jetzt wieder auf "öffne Form2" drücke passiert nix mehr....
    wie bekomme ich das hin, dass die Form sich dann erneut öffnet???

    Danke im Vorraus für Antworten :rofl:

    EDIT: sry code war erst falsch

    2 Mal editiert, zuletzt von mpsikorski (5. April 2011 um 14:45)

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 226, 92, 192, 124)
    $Button1 = GUICtrlCreateButton("öffne Form2", 0, 8, 225, 81, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Button1
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 223, 74, 193, 129)
    $Button2 = GUICtrlCreateButton("schliesse Form2", 0, 8, 217, 65, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2
    GUIDelete($Form2)
    ExitLoop
    EndSwitch
    WEnd

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

    EndSwitch
    WEnd

    [/autoit]

    Du hast in beiden GUIS $Button1 verwendet. Beim Aufruf der 2. GUI wird die Variable $Button1 überschrieben und somit reagiert deine 1. While Wend Schleife nicht mehr.
    2. Problem die 2. While Wend Schleife wird nie verlassen

  • Du löschst in deiner 2ten While zwar die GUI, verlässt aber nicht die Schleife.
    Dadurch bleibt dein Skript in der inneren Schleife gefangen und der Button
    von Form1 wird nie abgefragt. Ausserdem überschreibst du in der 2ten GUI die ID
    $button1 neu.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 226, 92, 192, 124)
    $Button1 = GUICtrlCreateButton("öffne Form2", 0, 8, 225, 81, $WS_GROUP)
    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
    #region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 223, 74, 193, 129)
    $Button2 = GUICtrlCreateButton("schliesse Form2", 0, 8, 217, 65, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2
    GUIDelete($form2)
    ExitLoop
    EndSwitch
    WEnd
    EndSwitch
    WEnd

    [/autoit]


    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    $gui1 = GUICreate("GUI-1", 259, 46)
    $Button1_1 = GUICtrlCreateButton("zu GUI-1", 8, 8, 75, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button2_1 = GUICtrlCreateButton("zu GUI-2", 88, 8, 75, 25, $WS_GROUP)
    $Button3_1 = GUICtrlCreateButton("zu GUI-3", 168, 8, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

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

    $gui2 = GUICreate("GUI-2", 259, 46)
    $Button1_2 = GUICtrlCreateButton("zu GUI-1", 8, 8, 75, 25, $WS_GROUP)
    $Button2_2 = GUICtrlCreateButton("zu GUI-2", 88, 8, 75, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button3_2 = GUICtrlCreateButton("zu GUI-3", 168, 8, 75, 25, $WS_GROUP)
    GUISetState(@SW_HIDE)

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

    $gui3 = GUICreate("GUI-3", 259, 46)
    $Button1_3 = GUICtrlCreateButton("zu GUI-1", 8, 8, 75, 25, $WS_GROUP)
    $Button2_3 = GUICtrlCreateButton("zu GUI-2", 88, 8, 75, 25, $WS_GROUP)
    $Button3_3 = GUICtrlCreateButton("zu GUI-3", 168, 8, 75, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_HIDE)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2_1
    GUISetState(@SW_HIDE, $gui1)
    GUISetState(@SW_SHOW, $gui2)
    Case $Button3_1
    GUISetState(@SW_HIDE, $gui1)
    GUISetState(@SW_SHOW, $gui3)
    Case $Button1_2
    GUISetState(@SW_HIDE, $gui2)
    GUISetState(@SW_SHOW, $gui1)
    Case $Button3_2
    GUISetState(@SW_HIDE, $gui2)
    GUISetState(@SW_SHOW, $gui3)
    Case $Button1_3
    GUISetState(@SW_HIDE, $gui3)
    GUISetState(@SW_SHOW, $gui1)
    Case $Button2_3
    GUISetState(@SW_HIDE, $gui3)
    GUISetState(@SW_SHOW, $gui2)
    EndSwitch
    WEnd

    [/autoit]
    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $gui1 = GUICreate("GUI-1", 259, 46)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    $Button1 = GUICtrlCreateButton("zu GUI-1", 8, 8, 75, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button2 = GUICtrlCreateButton("zu GUI-2", 88, 8, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_show2")
    $Button3 = GUICtrlCreateButton("zu GUI-3", 168, 8, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_show3")
    GUISetState(@SW_SHOW)

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

    $gui2 = GUICreate("GUI-2", 259, 46)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    $Button1 = GUICtrlCreateButton("zu GUI-1", 8, 8, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_show1")
    $Button2 = GUICtrlCreateButton("zu GUI-2", 88, 8, 75, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button3 = GUICtrlCreateButton("zu GUI-3", 168, 8, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_show3")
    GUISetState(@SW_HIDE)

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

    $gui3 = GUICreate("GUI-3", 259, 46)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    $Button1 = GUICtrlCreateButton("zu GUI-1", 8, 8, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_show1")
    $Button2 = GUICtrlCreateButton("zu GUI-2", 88, 8, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_show2")
    $Button3 = GUICtrlCreateButton("zu GUI-3", 168, 8, 75, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_HIDE)

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

    While 1
    Sleep(100)
    WEnd

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

    Func _show1()
    GUISetState(@SW_HIDE, $gui2)
    GUISetState(@SW_HIDE, $gui3)
    GUISetState(@SW_SHOW, $gui1)
    EndFunc ;==>_show1

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

    Func _show2()
    GUISetState(@SW_HIDE, $gui1)
    GUISetState(@SW_HIDE, $gui3)
    GUISetState(@SW_SHOW, $gui2)
    EndFunc ;==>_show2

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

    Func _show3()
    GUISetState(@SW_HIDE, $gui1)
    GUISetState(@SW_HIDE, $gui2)
    GUISetState(@SW_SHOW, $gui3)
    EndFunc ;==>_show3

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

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit]
  • vielen dank ihr habt mir gut geholfen =)
    gibt´s hier keinen Bedanken knopf im forum ???

    • Offizieller Beitrag

    Sowas brauchen wir nicht. Ein direktes bedanken ist uns lieber.

    Wenn dein Problem gelöst ist. 1.Post editieren und Prefix auf gelöst setzen.
    PS: Wen du Quellcode posten willst, einfach den Button mit dem Autoit Zeichen drücken und deinen Code zwischen
    [ Autoit) und ( /Autoit) einfügen ;). Bei Längeren Code bitte Spoiler verwenden , das ist der Button SP.