Sign in to follow this  
Followers 0
Guest LiQUiDNiTrO

GUI Window Problem

2 posts in this topic

#1 ·  Posted (edited)

Hi,

I have a problem with my script. If a user clicks on Options->Settings they get a new GUI like they should. If they click on X, it closes the entire app. I just want it to close the settings window. I have tried using another While loop, but that just prevents it from coming up. Here is the code:

#include <GUIConstants.au3>

GUICreate("MyApp", 800, 600)         ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)    ; will display an empty dialog box

$filemenu = GuiCtrlCreateMenu ("File")
$exititem = GuiCtrlCreateMenuitem ("Exit", $filemenu)
$optionsmenu = GuiCtrlCreateMenu ("Options")
$settingsitem = GuiCtrlCreateMenuitem ("Settings", $optionsmenu)
$helpmenu = GuiCtrlCreateMenu ("Help")
$aboutitem = GuiCtrlCreateMenuitem ("About", $helpmenu)


GuiSetState()

While 1
    $msg = GUIGetMsg()
    

    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        
        Case $msg = $exititem
            ExitLoop
            
        Case $msg = $settingsitem
            GUISetState(@SW_DISABLE)
            GUICreate("MyApp - Settings", 600, 450)      ; will create a dialog box that when displayed is centered 

            $okbutton = GuiCtrlCreateButton ("OK", 200, 425, 100, 20)
            $cancelbutton = GuiCtrlCreateButton ("Cancel", 300, 425, 100, 20)
            
            GUISetState ()
        Case $msg = $aboutitem
            Msgbox(0, "About", "GUI Menu Test")
    EndSelect
WEnd

GUIDelete()

Exit

This is probably a simple fix, but i'm new to AutoIt so i'm having some trouble figuring it out. I will pick up fast, as I know web scripting languages and some C/C++.

Thanks,

Kevin

Edited by LiQUiDNiTrO

Share this post


Link to post
Share on other sites



That works, but I get an error:

WARNING: $kid1: possibly used before declaration.
GUISwitch($kid1)

Also, when you close the settings window, the main window flashes.

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  
Followers 0