Problem bei 2 GUIs zur selbenzeit

  • Moin,

    Ich habe schon wieder eine Frage :)
    Und zwar wenn ich über eine GUI/MsgBox eine 2. GUI/MsgBox öffne und dann die vordere schließe, schließt sich auch die 1.

    Wie mach ich das die 1. offen bleibt?

    mfg

  • Stimmt ;)

    Ich hab mal eine Beispiel gemacht...
    Also

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 558, 320, 192, 124)
    $Button1 = GUICtrlCreateButton("2. Gui öffnen", 320, 264, 201, 41, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("Blablabla", 24, 8, 484, 193)
    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

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

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 409, 298, 216, 155)
    $Button1 = GUICtrlCreateButton("ggf zurück zur 1.gui", 256, 224, 129, 49, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("bla", 40, 232, 113, 41, $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]

    EndSwitch
    WEnd

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

    EndSwitch
    WEnd

    [/autoit]

    Also ich meine wenn man jetzt die 2. Gui öffnet und die dann durchs x wegmacht dann gehen ja beide weg ;)
    Wie änder ich das sodass nur die 2. Gui sich schließt...

  • Hi,
    das liegt daran das du in der inner While Schleife Exit statt Exitloop steht.

    Spoiler anzeigen
    [autoit]

    Case $Button1

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

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 409, 298, 216, 155)
    $Button1 = GUICtrlCreateButton("ggf zurück zur 1.gui", 256, 224, 129, 49, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("bla", 40, 232, 113, 41, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

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

    [/autoit]
  • Hi,
    meinst du sowas ?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    Opt("GUIOnEventMode", 1)
    Global $ShowedGUIs = 2

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

    $hGUI1 = GUICreate("GUI1", 500, 500, 50, 50)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_GUI1")
    GUISetState(@SW_SHOW)

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

    $hGUI2 = GUICreate("GUI2", 500, 500, 100, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_GUI2")
    GUISetState(@SW_SHOW)

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

    While $ShowedGUIs
    Sleep(50)
    WEnd

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

    Func _Exit_GUI1()
    GUIDelete($hGUI1)
    $ShowedGUIs -= 1
    EndFunc ;==>_Exit_GUI1

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

    Func _Exit_GUI2()
    GUIDelete($hGUI2)
    $ShowedGUIs -= 1
    EndFunc ;==>_Exit_GUI2

    [/autoit]
  • oder vielleicht so:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <Array.au3>
    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 558, 320, 192, 124)
    $Form1Button1 = GUICtrlCreateButton("2. Gui öffnen", 320, 264, 201, 41, $WS_GROUP)
    $Form1Label1 = GUICtrlCreateLabel("Blablabla", 24, 8, 484, 193)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    #region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Form2", 409, 298, 216, 155)
    $Form2Button1 = GUICtrlCreateButton("ggf zurück zur 1.gui", 256, 224, 129, 49, $WS_GROUP)
    $Form2Button2 = GUICtrlCreateButton("bla", 40, 232, 113, 41, $WS_GROUP)
    GUISetState(@SW_HIDE)
    #endregion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $nMsg[1])
    Case $Form1Button1
    GUISetState(@SW_SHOW, $Form2)
    Case $Form2Button1
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    WEnd

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.