2te Gui öffnen

  • Wolte mal so Fragen hab jetzt mein Programm halb fertig!. Kann jetzt dort z.b mein serial code eingeben.
    Nach richtiger eingabe sollte sich ein neues fenster öffnen wo ich alle meine button alles andere dann einfügen kann

    1 Gui offen
    nach richtiger eingabe
    2te Gui soll sich öffnen

    ist das i-wie in die richtung möglich ?

    Einmal editiert, zuletzt von Darki (2. Mai 2008 um 21:39)

  • Siehe hier

    Spoiler anzeigen
    [autoit]

    #include <GuiConstants.au3>
    Opt ("GUIOnEventMode", 1)
    Opt ('MustDeclareVars', 1)
    Dim $Btn_Exit1, $Btn_Exit2, $GUI1, $GUI2
    Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1
    Dim $OptionsMenu1, $OptionsItem1,$OptionsItem2,$OptionsItem3,$OptionsItem4, $separator1
    ;====================================================================================================
    $GUI1 = GUICreate("Left/Top Window", 300, 200, 10, 10)
    $OptionsMenu1 = GUICtrlCreateMenu("Options")
    $OptionsItem1 = GUICtrlCreateMenu("Docking", $OptionsMenu1)
    $OptionsItem2 = GUICtrlCreateMenuItem("Docked", $OptionsItem1)
    $separator1 = GUICtrlCreateMenuitem ("",$OptionsItem1)
    $OptionsItem3 = GUICtrlCreateMenuItem("Side By Side", $OptionsItem1)
    $OptionsItem4 = GUICtrlCreateMenuItem("Top And Bottom", $OptionsItem1)
    GUICtrlSetState($OptionsItem2, $GUI_CHECKED)
    GUICtrlSetState($OptionsItem3, $GUI_CHECKED)
    GUICtrlSetOnEvent($OptionsItem2, "_SetDocking")
    GUICtrlSetOnEvent($OptionsItem3, "_SetDockSideBySide")
    GUICtrlSetOnEvent($OptionsItem4, "_SetDockTopAndBottom")
    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
    $Btn_Exit1 = GUICtrlCreateButton("Exit", 175, 140, 90, 25)
    GUICtrlSetOnEvent($Btn_Exit1, "_Exit")
    ;======================================================================================================
    $GUI2 = GUICreate("Right/Bottom Window", 300, 200, 315, 10)
    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
    $Btn_Exit2 = GUICtrlCreateButton("Exit", 175, 140, 90, 25)
    GUICtrlSetOnEvent($Btn_Exit2, "_Exit")
    ;=========================================================================================================
    GUISetState(@SW_SHOW, $GUI2)
    GUISetState(@SW_SHOW, $GUI1)
    ;=========================================================================================================
    While 1
    If $Dock Then _KeepWindowsDocked()
    Sleep(10)
    WEnd
    Func _SetDocking()
    If BitAND(GUICtrlRead($OptionsItem2), $GUI_CHECKED) = $GUI_CHECKED Then
    GUICtrlSetState($OptionsItem2, $GUI_UNCHECKED)
    $Dock = 0
    Else
    GUICtrlSetState($OptionsItem2, $GUI_CHECKED)
    $Dock = 2
    EndIf
    If $Dock Then _KeepWindowsDocked()
    EndFunc

    Func _SetDockSideBySide()
    If BitAND(GUICtrlRead($OptionsItem3), $GUI_CHECKED) = $GUI_CHECKED Then
    GUICtrlSetState($OptionsItem3, $GUI_UNCHECKED)
    GUICtrlSetState($OptionsItem4, $GUI_CHECKED)
    $Dock_Location = 2
    Else
    GUICtrlSetState($OptionsItem3, $GUI_CHECKED)
    GUICtrlSetState($OptionsItem4, $GUI_UNCHECKED)
    $Dock_Location = 1
    If $Dock Then $Dock = 2
    EndIf
    If $Dock Then _KeepWindowsDocked()
    EndFunc
    Func _SetDockTopAndBottom()
    If BitAND(GUICtrlRead($OptionsItem4), $GUI_CHECKED) = $GUI_CHECKED Then
    GUICtrlSetState($OptionsItem4, $GUI_UNCHECKED)
    GUICtrlSetState($OptionsItem3, $GUI_CHECKED)
    $Dock_Location = 1
    Else
    GUICtrlSetState($OptionsItem4, $GUI_CHECKED)
    GUICtrlSetState($OptionsItem3, $GUI_UNCHECKED)
    $Dock_Location = 2
    If $Dock Then $Dock = 2
    EndIf
    If $Dock Then _KeepWindowsDocked()
    EndFunc ;==>_SetDocking1
    Func _KeepWindowsDocked()
    $p_win1 = WinGetPos($GUI1)
    $p_win2 = WinGetPos($GUI2)
    If $Dock_Location == 1 Then
    If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1),8) Or $Dock = 2) Then
    $x1 = $p_win1[0]
    $y1 = $p_win1[1]
    $x2 = $p_win1[2] + $x1
    $y2 = $y1
    WinMove($GUI2, "", $x2, $y2)
    $Dock = 1
    ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2),8)) Then
    $x2 = $p_win2[0]
    $y2 = $p_win2[1]
    $x1 = $p_win2[0] - $p_win1[2]
    $y1 = $y2
    WinMove($GUI1, "", $x1, $y1)
    EndIf
    Else
    If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1),8) Or $Dock = 2) Then
    $x1 = $p_win1[0]
    $y1 = $p_win1[1]
    $x2 = $x1
    $y2 = $p_win1[3] + $y1
    WinMove($GUI2, "", $x2, $y2)
    $Dock = 1
    ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2),8)) Then
    $x2 = $p_win2[0]
    $y2 = $p_win2[1]
    $x1 = $x2
    $y1 = $p_win2[1] - $p_win1[3]
    WinMove($GUI1, "", $x1, $y1)
    EndIf
    EndIf
    EndFunc ;==>_KeepWindowsDocked
    Func _Exit()
    Exit
    EndFunc ;==>_Exit
    Func SpecialEvents()
    Select
    Case @GUI_CtrlId = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    EndFunc ;==>SpecialEvents

    [/autoit]

    Edit BugFix: AutoIt-Tag und Spoiler gesetzt

    Gruss Hans-Jürgen ^^

    Einmal editiert, zuletzt von BugFix (1. Mai 2008 um 17:08)

    • Offizieller Beitrag

    Hi,
    das war aber mit Kanonen auf Spatzen... ;)

    Er will doch nur, dass eine 2.te GUI aufpoppt.
    Etwas einfacher:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Opt("GUIOnEventMode", 1)

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

    $gui1 = GUICreate('GUI 1')
    GUISetOnEvent($GUI_EVENT_CLOSE, 'GUI1_close')
    $btn = GUICtrlCreateButton('Zeige GUI 2', 10, 20, 100, 20)
    GUICtrlSetOnEvent(-1, 'ClickButton')

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

    $gui2 = GUICreate('GUI 2')
    GUISetOnEvent($GUI_EVENT_CLOSE, 'GUI2_close')

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

    GUISetState(@SW_SHOW, $gui1)

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

    While True
    Sleep(100)
    WEnd

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

    Func GUI1_close()
    Exit
    EndFunc

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

    Func GUI2_close()
    GUISetState(@SW_HIDE, $gui2)
    EndFunc

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

    Func ClickButton()
    GUISetState(@SW_SHOW, $gui2)
    EndFunc

    [/autoit]
  • dankeschön ihr beide

    Geht das auch ohne onevent mode ?
    Ich hab das so

    [autoit]

    Func _notactivate()
    MsgBox(4096, "", "Key ungültig")
    exit
    EndFunc

    Func _activate()
    MsgBox(4096, "", "Key gültig, viel Spaß mit dem Programm :D")

    EndFunc

    [/autoit]

    Und nur beim _active soll dann eben dich die Gui öffnen

    2 Mal editiert, zuletzt von Darki (1. Mai 2008 um 18:43)

  • z.B. dann so:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    $gui1 = GUICreate('GUI 1')

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

    $btn = GUICtrlCreateButton('Zeige GUI 2', 10, 20, 100, 20)

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

    $gui2 = GUICreate('GUI 2',-1,-1,100)

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

    GUISetState(@SW_SHOW, $gui1)

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

    While True
    $ExtMsg = GUIGetMsg(1)
    $nMsg = $ExtMsg[0]
    Switch $ExtMsg[1] ; GUISwitch
    Case $gui1 ; :)
    Select ; Actions GUI1
    Case $nMsg = $btn
    GUISetState(@SW_SHOW, $gui2)
    Case $nMsg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    Case $gui2
    Select ; Actions GUI2
    Case $nMsg = $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $gui2)
    EndSelect
    EndSwitch
    WEnd

    [/autoit]
  • genau sowas!Danke. Konnt mich nicht direkt ausdrücken sry
    aber wünsch euch dennoch einen schönen Donnerstag Abend und Feiert schön

  • mh shit Habs jetzt mal rein gebaut aber mein exit button geht nicht mehr oder die 2 gui öffnet sich trotzdem ob wohl die sich nur öffnen darf wenn die serial richtig ist ?
    wenn se falsch ist soll sich das programm einfach schlißen aber funktioniert einfach nicht kann jemand helfen
    Privat dann ?

  • [autoit]

    Func _activate()
    MsgBox(4096, "", "Key gültig, viel Spaß mit dem Programm :D")
    If GUICtrlRead($gui2) Then
    EndIf
    ; programmcode

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

    EndFunc

    [/autoit]

    Haben Prblem ich hab das jetzt so in die Func rein geschrieben aber es öffnet sich nicht die zweite gui
    die anderen hab ich ausprobiert da kamen viele ehler nix ging mehr richtig und da ich ncoh nciht so gut darin bin wolte ich noch mals fragen

    Habs geschaft selber zu lösen ! Danköö

    Einmal editiert, zuletzt von Darki (2. Mai 2008 um 21:39)