Jump to content
Sign in to follow this  
sumit

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

Recommended Posts

sumit

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 ()

Share this post


Link to post
Share on other sites
sumit

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
    
    

            
        

        
            
                
                    

        
        
            
                
                    
                
            
            
            
        
    


                
            
            
                
                    
                    
                    
                
                
                    
                
            
        

        
    

    
        
            Share this post
            
            Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    

    

                    
                        
                    
                
                    
                    
                    






    

    
        
            
Jos
              

    
        
    
             1,292
    
        
    

        
        
            

    
        
    

        
    
    
        
Jos   

    
        
    
             1,292
    
        
    

        
        
            
                Je maintiendrai
            
            

            
                

    
        
    

            
            Developers
            
                
            
            
                

    
        
    
             1,292
    
        
    

                28,117 posts
                
                

            
        
    
    
        


    

    
        
            
                
                    Report post
                
                
                
                    
                
                
            
        

        
            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 ()


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
sumit

#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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.