charon

Gui within a GUI

3 posts in this topic

How can I create another GUI within my GUI.  Example: I have a menu in my GUI called options. Click options to set preferences which require several input and drop down boxes so I created another GUI. When I close the 2nd GUI it closes everything instead of going back to the main GUI.  Here is an example:

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $iOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)


    ;Start top menu
    $OptionMenu = GUICtrlCreateMenu("&Options")
    $testitem = GUICtrlCreateMenuItem("Global", $OptionMenu)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iOK
                ExitLoop
            Case $testitem
                SetOptions()
    EndSwitch


     ;If $msg = $testitem Then
         ;MsgBox($MB_SYSTEMMODAL, "test", "testing...")
         ;HotKeySet("^x", "RemedyFunc")
        ; SetOptions()
     ;EndIf

    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example



;GUI Functions
Func SetOptions()
    Local $msg, $sItem
    GUICreate("Options", 380, 230, 100, 200, -1)   ;5 buttons   width/height/left/top
     GUICtrlCreateLabel("Delay ", 10, 10, 40) ; first cell 70 width
    $Input = GUICtrlCreateInput("500", 50, 10, 40, 20)  ;left/top/width/height
    GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button
    Local $Go = GUICtrlCreateButton("Go", 120, 10, 85, 25)
    GUISetState(@SW_SHOW) ; will display an empty dialog box with a combo control with focus on

;    Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Share this post


Link to post
Share on other sites



Charon,

I recommend reading the Managing Multiple GUIs tutorial in the Wiki. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

It's because it's finishing the script after the second function. ;)

Have a look at what Melba suggested and I'm sure you will find your way. Anymore questions post script and we'll be sure to help. :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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