Mehere GUI's ?

  • Hallo,
    ich möchte ein Programm mit mehreren GUI's machen,
    jetzt wollte ich wissen wie ich das am besten mache,
    wenn ich am anfang das erste GUI anzeigen lasse und wenn ich auf einen Button drücke, dass dann ein anderes GUI angezeigt wird?

    Ich hoffe dass ihr versteht was ich meine.

    Einmal editiert, zuletzt von morfi93 (15. Juli 2008 um 22:51)

  • Meintest Du etwa so:

    [autoit]


    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("Form1", 230, 152, 193, 125)
    $Gui1 = GUICtrlCreateLabel("Gui1", 40, 8, 86, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Gui2", 40, 72, 129, 49, 0)
    GUICtrlSetOnEvent($Button1,"ShowGui2")

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

    GUISetState(@SW_SHOW)

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

    $Form2 = GUICreate("Form2", 330, 172, 223, 145)
    $Gui2 = GUICtrlCreateLabel("Gui2", 40, 8, 86, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Gui1", 40, 72, 129, 49, 0)
    GUICtrlSetOnEvent($Button2,"ShowGui1")

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

    Func ShowGui2()
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    EndFunc

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

    Func ShowGui1()
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)
    EndFunc

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

    While 1
    sleep(100)
    WEnd

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

    Peter

  • Hey, danke erstmal für deine schnelle Antwort.
    Genau so habe ich es gemeint.
    Hier erstmal mein Code:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>

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

    Global $UserFolder = @ScriptDir & "\Users\"

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 331, 126, 347, 249)
    GUISetBkColor(0xA6CAF0)
    $Form1Label1 = GUICtrlCreateLabel("Benutzername:", 8, 8, 75, 15)
    $Form1Input1 = GUICtrlCreateInput("", 8, 24, 313, 21)
    $Form1Label2 = GUICtrlCreateLabel("Passwort:", 8, 56, 50, 15)
    $Form1Input2 = GUICtrlCreateInput("", 8, 72, 313, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
    $Form1Button1 = GUICtrlCreateButton("Login", 8, 96, 75, 25, 0)
    $Form1Button2 = GUICtrlCreateButton("Zurücksetzen", 88, 96, 75, 25, 0)
    $Form1Button3 = GUICtrlCreateButton("Registrieren", 168, 96, 75, 25, 0)
    $Form1Button4 = GUICtrlCreateButton("Beenden", 248, 96, 75, 25, 0)
    GUISetState(@SW_SHOW)
    $Form3 = GUICreate("Registrieren", 277, 169, 381, 233, -1, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xA6CAF0)
    $Form3Label1 = GUICtrlCreateLabel("Benutzername:", 10, 8, 75, 15)
    $Form3Input1 = GUICtrlCreateInput("", 10, 25, 256, 21)
    $Form3Label2 = GUICtrlCreateLabel("Passwort:", 10, 55, 50, 15)
    $Form3Input2 = GUICtrlCreateInput("", 10, 70, 256, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
    $Form3Label3 = GUICtrlCreateLabel("Passwort wiederholen:", 10, 100, 110, 15)
    $Form3Input3 = GUICtrlCreateInput("", 10, 115, 256, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
    $Form3Button1 = GUICtrlCreateButton("Registrieren", 10, 140, 75, 25, 0)
    $Form3Button2 = GUICtrlCreateButton("Felder zurücksetzen", 85, 140, 110, 25, 0)
    $Form3Button3 = GUICtrlCreateButton("Beenden", 195, 140, 70, 25, 0)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg(1)
    Select
    Case $nMsg[0] = $GUI_EVENT_CLOSE and $nMsg[1] = $Form1
    Exit
    Case $nMsg[0] = $Form1Button4 and $nMsg[1] = $Form1
    Exit
    Case $nMsg[0] = $Form1Button3 and $nMsg[1] = $Form1
    GUISetState(@SW_SHOW, $Form3)
    Case $nMsg[0] = $GUI_EVENT_CLOSE and $nMsg[1] = $Form3
    GUISetState(@SW_HIDE, $Form3)
    Case $nMsg[0] = $Form3Button3 and $nMsg[1] = $Form3
    GUISetState(@SW_HIDE, $Form3)
    EndSelect
    WEnd

    [/autoit]

    Ich habe jetzt leider ein kleines Problem.
    Und zwar:
    Wenn ich das erste mal auf Registrieren klicke, dann erscheint mir das GUI Fenster langsam auf, aber wenn ich dann öfters draufdrücke, dann erscheint es nicht langsam sondern blitzt einfach auf und das will ich nicht.

    • Offizieller Beitrag

    Und falls du nur mit GUIGetMsg arbeitest:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    $gui1 = GUICreate('GUI 1')
    $btn1 = GUICtrlCreateButton('Zeige GUI 2', 10, 20, 100, 20)

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

    $gui2 = GUICreate('GUI 2')
    $btn2 = GUICtrlCreateButton('Button 2', 10, 20, 100, 20)

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

    GUISetState(@SW_SHOW, $gui1)

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

    While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1] ; Window Handle
    Case $gui1
    Switch $msg[0] ; Event
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btn1
    GUISetState(@SW_HIDE, $gui1)
    GUISetState(@SW_SHOW, $gui2)
    EndSwitch
    Case $gui2
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_SHOW, $gui1)
    GUISetState(@SW_HIDE, $gui2)
    Case $btn2
    MsgBox(0, '', 'Button 2 geklickt')
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]
  • Weil ich dann Lauter Funktionen machen muss.

    [EDIT]
    Man kann keine Parameter übergeben!

    Einmal editiert, zuletzt von morfi93 (15. Juli 2008 um 22:50)

  • Also ich würde sowieso die Fenster (GUI's) die Du nicht brauchst ausblenden (Hide).

    Also so:

    Spoiler anzeigen
    [autoit]

    #include<EditConstants.au3>
    #include<GUIConstantsEx.au3>

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

    Global $UserFolder = @ScriptDir & "\Users\"

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 331, 126, 347, 249)
    GUISetBkColor(0xA6CAF0)
    $Form1Label1 = GUICtrlCreateLabel("Benutzername:", 8, 8, 75, 15)
    $Form1Input1 = GUICtrlCreateInput("", 8, 24, 313, 21)
    $Form1Label2 = GUICtrlCreateLabel("Passwort:", 8, 56, 50, 15)
    $Form1Input2 = GUICtrlCreateInput("", 8, 72, 313, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
    $Form1Button1 = GUICtrlCreateButton("Login", 8, 96, 75, 25, 0)
    $Form1Button2 = GUICtrlCreateButton("Zurücksetzen", 88, 96, 75, 25, 0)
    $Form1Button3 = GUICtrlCreateButton("Registrieren", 168, 96, 75, 25, 0)
    $Form1Button4 = GUICtrlCreateButton("Beenden", 248, 96, 75, 25, 0)
    GUISetState(@SW_SHOW)
    $Form3 = GUICreate("Registrieren", 277, 169, 381, 233, -1)
    GUISetBkColor(0xA6CAF0)
    $Form3Label1 = GUICtrlCreateLabel("Benutzername:", 10, 8, 75, 15)
    $Form3Input1 = GUICtrlCreateInput("", 10, 25, 256, 21)
    $Form3Label2 = GUICtrlCreateLabel("Passwort:", 10, 55, 50, 15)
    $Form3Input2 = GUICtrlCreateInput("", 10, 70, 256, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
    $Form3Label3 = GUICtrlCreateLabel("Passwort wiederholen:", 10, 100, 110, 15)
    $Form3Input3 = GUICtrlCreateInput("", 10, 115, 256, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
    $Form3Button1 = GUICtrlCreateButton("Registrieren", 10, 140, 75, 25, 0)
    $Form3Button2 = GUICtrlCreateButton("Felder zurücksetzen", 85, 140, 110, 25, 0)
    $Form3Button3 = GUICtrlCreateButton("Beenden", 195, 140, 70, 25, 0)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg(1)
    Select
    Case $nMsg[0] = $GUI_EVENT_CLOSE and $nMsg[1] = $Form1
    Exit
    Case $nMsg[0] = $Form1Button4 and $nMsg[1] = $Form1
    Exit
    Case $nMsg[0] = $Form1Button3 and $nMsg[1] = $Form1
    GUISetState(@SW_SHOW, $Form3)
    GUISetState(@SW_HIDE, $Form1)
    Case $nMsg[0] = $GUI_EVENT_CLOSE and $nMsg[1] = $Form3
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_SHOW, $Form1)
    Case $nMsg[0] = $Form3Button3 and $nMsg[1] = $Form3
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_SHOW, $Form1)
    EndSelect
    WEnd

    [/autoit]

    Die Includes richtig gesetzt geht es gleichbleibend schnell. ;)

    Crazy-A.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    k3mrwmIBHejryPvylQSFieDF5f3VOnk6iLAVBGVhKQegrFuWr3iraNIblLweSW4WgqI0SrRbS7U5jI3sn50R4a15Cthu1bEr

  • Danke erstmal für die Info, aber mir kommt es trotzdem noch unterschiedlich vor.

    [EDIT]
    Ich danke nochmal allen für eure Hilfe, ich werde mich an euren Hilfen orientieren und es so weitermachen.
    THX

    Einmal editiert, zuletzt von morfi93 (15. Juli 2008 um 22:51)