jfcby Posted June 15, 2009 Posted June 15, 2009 Hi, I have a script with two GUI's. When the script is run the main gui is started. When a selection is made from the combobox the main gui continues to run and starts the second gui. When the second gui is closed the first gui does nothing. How can I get the controls on the main gui to work after the second gui is closed? CODE #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIComboBox.au3> Opt('MustDeclareVars', 1) Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. HotKeySet("{ESC}", "_Exit") ;Declare vairables for Func _mGUI() Global $mGui, $combo1 ;Declare vairables for Func _sGUI() Global $cGui, $combl1 _mGui() Func _mGui() ; Local $mGuiTitle, $btnClose, $cbItm[100][100], $Msg $mGuiTitle = "Main GUI" $mGui = GUICreate($mGuiTitle, 200, 26, 735, 1, BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW)) $btnClose = GUICtrlCreateButton("X", 175, 5, 20, 20) ;Combox dropdown $cbItm[1][1] = "Select Option" ;Default $cbItm[1][2] = "Option 1" $cbItm[1][3] = "Option 2" $combo1 = GUICtrlCreateCombo("", 5, 3, 125, 15) ; create first item For $i = 1 To 3 GUICtrlSetData(-1, $cbItm[1][$i], $cbItm[1][1]) ; add other item and set a new default Next GUISetState() WinSetOnTop($mGui, "", 1) ;window stays on top ;*** Tray Menu *** ;TrayCreateItem("") Local $trmShow = TrayCreateItem("Show") TrayCreateItem("") Local $trmExit = TrayCreateItem("Exit") TraySetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE _Exit() Case $btnClose _Exit() Case $combo1 If GUICtrlRead($combo1) = $cbItm[1][2] Then MsgBox(0, "", "ComboboxItem 2") ElseIf GUICtrlRead($combo1) = $cbItm[1][3] Then MsgBox(0, "", "ComboboxItem 3") EndIf _sGui() ContinueLoop Case Else EndSwitch ;Tray Menu Local $Tmsg = TrayGetMsg() Select Case $Tmsg = 0 ContinueLoop Case $Tmsg = $trmExit ;MsgBox(0, "", "Tray Exit") _Exit() Case $Tmsg = $trmShow ;MsgBox(0, "", "Show") EndSelect WEnd GUIDelete() ;return 1 EndFunc ;==>_mGui Func _sGui() ; Local $cGuiTitle, $sMsg, $sTmsg, $cbItm[100][100] $cGuiTitle = "Sub GUI" $cGui = GUICreate($cGuiTitle, 200, 27, 735, 100) ;, -1, -1, $MguiTitle) ;Combox dropdown $cbItm[1][1] = "Select Option" ;Default $cbItm[1][2] = "Option 1" $cbItm[1][3] = "Option 2" ;"Reply All w/ Attach" $combo1 = GUICtrlCreateCombo($cbItm[1][1], 5, 3, 160, 15) ; create first item For $i = 1 To 3 GUICtrlSetData(-1, $cbItm[1][$i], $cbItm[1][1]) ; add other item and set a new default Next GUISetState() WinSetOnTop($cGuiTitle, "", 1) ;window stays on top ;*** Tray Menu *** Local $trmExit = TrayCreateItem("Exit") TraySetState() While 1 $sMsg = GUIGetMsg() Select Case $sMsg = $GUI_EVENT_CLOSE ;_Exit() ExitLoop Case $sMsg = $combo1 ;Example: GUICtrlRead($combo1) = $cbItm[1][1] If _GUICtrlComboBox_GetCurSel($combo1) = 1 Then ;"Reply All w/ Attach" & no message MsgBox(0, "", "ComboboxItem 2") ElseIf _GUICtrlComboBox_GetCurSel($combo1) >= 2 Then ;"Reply All w/ Attach" & message 001 - 005 MsgBox(0, "", "ComboboxItem 3") EndIf Case Else EndSelect ;Tray Menu Local $sTmsg = TrayGetMsg() Select Case $sTmsg = 0 ContinueLoop Case $sTmsg = $trmExit ;MsgBox(0, "", "Tray Exit") _Exit() EndSelect WEnd GUIDelete() EndFunc ;==>_sGui Func _Exit() Exit EndFunc ;==>_Exit Thank you for your help, jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****
Moderators Melba23 Posted June 15, 2009 Moderators Posted June 15, 2009 jfcby,You used the variable $combo1 to store the ControlID in both GUIs, so when you return to the first GUI, GUIGetMsg no longer recognises the first value. You even declared a second combo name ($combl1) and then did not use it! ;-)Just change lines 92 and 110 and all should work without a problem.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now