Sign in to follow this  
Followers 0
=sinister=

Yet Another 2 GUI Problem

3 posts in this topic

#1 ·  Posted (edited)

><.... Not sure where to start. I want to create 2 GUI's.

#Include <GUIConstants.au3>

$GUI = GUICreate($Name, 300, 300, -1, -1)
$File = GUICtrlCreateMenu("File")
$Open = GUICtrlCreateMenuItem("Open", $File)
$Options = GUICtrlCreateMenu("Options")
$Settings = GUICtrlCreateMenuItem("Settings", $Options)
$Edit = GUICtrlCreateEdit("", 2, 25, 296, 225)
GUISetState(@SW_Show, $GUI)

While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_Event_Close
Exit
Case $Msg = $GUI_Event_Close
GUISetState(@SW_Hide, $GUI_Settings)
Case $Msg = $Open
$Dialog = FileOpen(FileOpenDialog("Please Choose A File", @ScriptDir & "\", "Travel Files (*.trv)"), 0)
If $Dialog = @Error Then
;Do Nothing
Else
$Read = FileRead($Dialog)
GUICtrlSetData($Edit, $Read)
EndIf
Case $Msg = $Settings
$GUI_Settings = GUICreate($Name & " " & "Settings", 150, 100, -1, -1)
GUISetState(@SW_Show, $GUI_Settings)
EndSelect
WEnd

The problem is I don't know how to get only 1 to close, and which one was closed. Any ideas?

Edited by =sinister=

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

try this..

[edit] i added some comments..

#Include <GUIConstants.au3>
$Name = 'name' ; missing variable

$GUI = GUICreate($Name, 300, 300, -1, -1)
$File = GUICtrlCreateMenu("File")
$Open = GUICtrlCreateMenuItem("Open", $File)
$Options = GUICtrlCreateMenu("Options")
$Settings = GUICtrlCreateMenuItem("Settings", $Options)
$Edit = GUICtrlCreateEdit("", 2, 25, 296, 225)
GUISetState(@SW_Show, $GUI)

;create gui once, and hide it
$GUI_Settings = GUICreate($Name & " " & "Settings", 150, 100)
GUISetState(@SW_HIDE, $GUI_Settings)

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_Event_Close ; you only need 1 event (2 or more of same event will be ingored.)
            If WinGetHandle('') = $GUI Then ;checks if the active window handle = $GUI
                Exit
            Else
                GUISetState(@SW_Hide, WinGetHandle('')) ;hide any extra windows by handle, you can change this to $GUI_Settings
            EndIf
        Case $Msg = $Open
            $Dialog = FileOpen(FileOpenDialog("Please Choose A File", @ScriptDir & "\", "Travel Files (*.trv)"), 0)
            If Not $Dialog = @Error Then ;the then do nothing was it needed?
                $Read = FileRead($Dialog)
                GUICtrlSetData($Edit, $Read)
            EndIf
        Case $Msg = $Settings
            GUISetState(@SW_SHOW, $GUI_Settings) ;show the gui_settings window
    EndSelect
WEnd
Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

MrRevoked,

This was exactly what I was looking for. Thank you!! I also appreciate you commenting the script to help me even more. That missing variable was part of another script. See I organize my scripts into certain files ><. I'm a neat freak. Anyways, thank you for the help.

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