Jump to content

How to come back to first gui after closing 2nd gui


sumit
 Share

Recommended Posts

Please run this code . As you can see when selecting the item in first Gui ..... You get second Gui, Now my problem is when i Close the second Gui either by selecting cancel or close button I should be able to get back to first Gui ....... What should I do .

Also when i click Close button ( X sign ) in 2nd window it doesnt close the first time .... it closes on 2nd click..... why is that happening.

Any help would be appreciated.

CODE
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form2 = GUICreate("Dias Configuration", 368, 141, 321, 254)

$GroupBox2 = GUICtrlCreateGroup("", 8, 1, 265, 129)

$List2 = GUICtrlCreateList("", 32, 32, 217, 58)

GUICtrlSetData($List2, 'Control Card')

GUICtrlCreateGroup("", -99, -99, 1, 1)

$2Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)

$2Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Do

$mMsg = GUIGetMsg()

If $mMsg = $2Button1 Then

$H = GUICtrlRead($List2)

If $H = "Control Card" Then

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Control Card", 368, 141, 321, 254)

$GroupBox1 = GUICtrlCreateGroup("", 8, 1, 265, 129)

$List1 = GUICtrlCreateList("", 32, 32, 217, 58)

GUICtrlSetData($List1, 'Login')

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)

$Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Do

$nMsg = GUIGetMsg()

If $nMsg = $Button1 Then

$G = GUICtrlRead($List1)

If $G = "Login" Then

; Do Something

EndIf

EndIf

If $nMsg = $Button2 Then

; Here I want to Close this Gui and Restore First Gui

Exit

EndIf

Until $nMsg = $Gui_Event_Close () ; Here also I want to Close this Gui and Restore First Gui

EndIf

EndIf

if $mMsg = $2Button2 Then

Exit

Endif

Until $mMsg = $Gui_Event_Close ()

Link to comment
Share on other sites

GUIDelete("2nd GUI")

Ok with your advice Im able to get back to first GUI on clicking cancel in 2nd GUI

Heres the modified code

CODE
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Dias Configuration", 368, 141, 321, 254)
$GroupBox2 = GUICtrlCreateGroup("", 8, 1, 265, 129)
$List2 = GUICtrlCreateList("", 32, 32, 217, 58)
GUICtrlSetData($List2, 'Control Card')

GUICtrlCreateGroup("", -99, -99, 1, 1)
$2Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)
$2Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Do


    $mMsg = GUIGetMsg()
    If $mMsg = $2Button1 Then
        $H = GUICtrlRead($List2)
        If $H = "Control Card" Then

            #Region ### START Koda GUI section ### Form=
            $Form1 = GUICreate("Control Card", 368, 141, 321, 254)
            $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 265, 129)
            $List1 = GUICtrlCreateList("", 32, 32, 217, 58)
            GUICtrlSetData($List1, 'Login')
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)
            $Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###

            Do
                $nMsg = GUIGetMsg()


                If $nMsg = $Button1 Then
                    $G = GUICtrlRead($List1)
                    If $G = "Login" Then
                        ; Do Something
                    EndIf
                EndIf
                If $nMsg = $Button2 Then
                    GUIDelete($Form1)
                    GUISetState($Form2,@SW_RESTORE)
                EndIf
                
                
            Until $nMsg = $Gui_Event_Close () ; Here also I want to Close this Gui and Restore First Gui
        EndIf
    EndIf
    
    if $mMsg = $2Button2 Then
        Exit
    Endif
Until $mMsg = $Gui_Event_Close ()

[\code]


but i still have 2 problems

1. After getting back to first Gui Im not able to go to 2nd gui again
2. ON pressing the X button in 2nd gui i dont reach first GUI


            
                


    Edited  by sumit
    
    

            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    
        
            
                
                    Developers
                
                
                
                
            
        
    

    
        
            
                


    
        
    

                
                
                
                
                    
                        

                    
                
            
        
        
            
                


Jos
            
            
                Posted 
                
            
        
    
    
        


Jos
            
        
        
            
                
                    


    
        
    

                    
                        
                    
                    
                        

                    
                
            
            
                Developers
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 34.3k
                            
                                
                            
                        
                        
                            
                                
                                    
                                        
                                        156
                                
                                    
                                
                            
                        
                    
                
            
            
                

    
    
        
Je maintiendrai
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                        Developers
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            #Region ### START Koda GUI section ### Form=
#Include<GuiConstants.au3>
$Form2 = GUICreate("Dias Configuration", 368, 141, 321, 254)
$GroupBox2 = GUICtrlCreateGroup("", 8, 1, 265, 129)
$List2 = GUICtrlCreateList("", 32, 32, 217, 58)
GUICtrlSetData($List2, 'Control Card')
GUICtrlCreateGroup("", -99, -99, 1, 1)
$2Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)
$2Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Do
    $mMsg = GUIGetMsg()
    If $mMsg = $2Button1 Then
        $H = GUICtrlRead($List2)
        If $H = "Control Card" Then
            #Region ### START Koda GUI section ### Form=
            $Form1 = GUICreate("Control Card", 368, 141, 321, 254)
            $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 265, 129)
            $List1 = GUICtrlCreateList("", 32, 32, 217, 58)
            GUICtrlSetData($List1, 'Login')
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)
            $Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###
            Do
                $nMsg = GUIGetMsg()
                If $nMsg = $Button1 Then
                    $G = GUICtrlRead($List1)
                    If $G = "Login" Then
                    ; Do Something
                    EndIf
                EndIf
                If $nMsg = $Button2 Then
                    ExitLoop
                EndIf
            Until $nMsg = $Gui_Event_Close; Here also I want to Close this Gui and Restore First Gui
            GUIDelete($Form1)
            GUISetState($Form2, @SW_RESTORE)
        EndIf
    EndIf
    If $mMsg = $2Button2 Then
        Exit
    EndIf
Until $mMsg = $Gui_Event_Close ()

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#Region ### START Koda GUI section ### Form=
#Include<GuiConstants.au3>
$Form2 = GUICreate("Dias Configuration", 368, 141, 321, 254)
$GroupBox2 = GUICtrlCreateGroup("", 8, 1, 265, 129)
$List2 = GUICtrlCreateList("", 32, 32, 217, 58)
GUICtrlSetData($List2, 'Control Card')
GUICtrlCreateGroup("", -99, -99, 1, 1)
$2Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)
$2Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Do
    $mMsg = GUIGetMsg()
    If $mMsg = $2Button1 Then
        $H = GUICtrlRead($List2)
        If $H = "Control Card" Then
            #Region ### START Koda GUI section ### Form=
            $Form1 = GUICreate("Control Card", 368, 141, 321, 254)
            $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 265, 129)
            $List1 = GUICtrlCreateList("", 32, 32, 217, 58)
            GUICtrlSetData($List1, 'Login')
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Button1 = GUICtrlCreateButton("&OK", 286, 11, 75, 25, 0)
            $Button2 = GUICtrlCreateButton("&Cancel", 285, 44, 75, 25, 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###
            Do
                $nMsg = GUIGetMsg()
                If $nMsg = $Button1 Then
                    $G = GUICtrlRead($List1)
                    If $G = "Login" Then
                ; Do Something
                    EndIf
                EndIf
                If $nMsg = $Button2 Then
                    ExitLoop
                EndIf
            Until $nMsg = $Gui_Event_Close; Here also I want to Close this Gui and Restore First Gui
            GUIDelete($Form1)
            GUISetState($Form2, @SW_RESTORE)
        EndIf
    EndIf
    If $mMsg = $2Button2 Then
        Exit
    EndIf
Until $mMsg = $Gui_Event_Close ()
A reply from the Moderator ..... The solution had to be perfect............ thanks a lot
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...