FrozenTeeth Posted March 23, 2010 Share Posted March 23, 2010 (edited) I'v been beating my head over this. I searched and search the forum and actualy found a recent thread with a similar issue 2 GUI'sI have a larger program but I have pulled out all no essental stuff and it still doesn't work. I can start the the main GUI and then open the second GUI (my settings GUI) but it won't let me close the GUI and return to the main GUI. From the code you see I've tried to put the GUI exit code in diffrent spots and it still fails. What am I doing wrong?? Thanks for the help.expandcollapse popup#include <GuiComboBox.au3> #include <GuiComboBoxEx.au3> #include <GuiEdit.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> Opt("GUIOnEventMode", 1) $formLink = GUICreate("Link", 801, 571, 192, 124) $btnStart = GUICtrlCreateButton("Start", 10, 10, 80, 30) Local $formGlobal, $msg2 GUICtrlSetOnEvent($btnStart, "btnStartClick") GUISetState(@SW_SHOW) ; ; main loop ; While 1 Sleep(100) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func btnStartClick() globalSettingsGUI() EndFunc ;==>btnStartClick ; Func globalSettingsGUI() GUISetState(@SW_DISABLE, $formLink) $formGlobal = GUICreate("Global Settings", 506, 271, 228, 426) $btnGlobalSaveSettings = GUICtrlCreateButton("Save Settings", 372, 222, 125, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "btnGlobalSaveSettingsClick") GUISetState(@SW_SHOW) GUISwitch($formGlobal) ; ; loop ; While 1 Sleep(100) $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE MsgBox(0, "test", "test") GUISetState(@SW_DISABLE, $formGlobal) GUISetState(@SW_ENABLE, $formLink) GUISwitch($formLink) GUIDelete($formGlobal) Return EndSelect WEnd EndFunc ;==>globalSettingsGUI Func formGlobalClose() MsgBox(0, "test", "test") GUISetState(@SW_DISABLE, $formGlobal) GUISetState(@SW_ENABLE, $formLink) GUISwitch($formLink) GUIDelete($formGlobal) EndFunc ;==>formGlobalClose Func formGlobalMaximize() EndFunc ;==>formGlobalMaximize Func formGlobalMinimize() EndFunc ;==>formGlobalMinimize Func formGlobalRestore() EndFunc ;==>formGlobalRestore Func btnGlobalSaveSettingsClick() MsgBox(0, "test", "test") GUISetState(@SW_DISABLE, $formGlobal) GUISetState(@SW_ENABLE, $formLink) GUISwitch($formLink) GUIDelete($formGlobal) EndFunc ;==>btnGlobalSaveSettingsClick Edited March 23, 2010 by FrozenTeeth Link to comment Share on other sites More sharing options...
KaFu Posted March 23, 2010 Share Posted March 23, 2010 Several things... You're mixing up onevent and getmsg methods. Stick to onevent, add a sleep to the main loop and set the exit event with guisetonevent. Your second gui is created in a function. From within a function called by onevent you can not call another event function. Either create the second gui also (hidden) in the main part and just unhide it in the function, or switch to guimsg method in the function and back to onevent before returning to the main loop. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Yoriz Posted March 23, 2010 Share Posted March 23, 2010 Dont mix oneventmode and message loop modes expandcollapse popup#include <GuiComboBox.au3> #include <GuiComboBoxEx.au3> #include <GuiEdit.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> HotKeySet("{ESC}","_Exit") Func _Exit() Exit EndFunc Opt("GUIOnEventMode", 1) $formLink = GUICreate("Link", 801, 571, 192, 124) $btnStart = GUICtrlCreateButton("Start", 10, 10, 80, 30) Local $formGlobal, $msg2 GUICtrlSetOnEvent($btnStart, "btnStartClick") GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE,"_closeMainWindow",$formLink) Func _closeMainWindow() GUIDelete($formLink) Exit EndFunc ; ; main loop ; While 1 Sleep(100) ;~ $msg = GUIGetMsg() ;~ Select ;~ Case $msg = $GUI_EVENT_CLOSE ;~ Exit ;~ EndSelect WEnd Func btnStartClick() globalSettingsGUI() EndFunc ;==>btnStartClick ; Func globalSettingsGUI() GUISetState(@SW_DISABLE, $formLink) $formGlobal = GUICreate("Global Settings", 506, 271, 228, 426) $btnGlobalSaveSettings = GUICtrlCreateButton("Save Settings", 372, 222, 125, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "btnGlobalSaveSettingsClick") GUISetState(@SW_SHOW) ;~ GUISwitch($formGlobal) ; ; loop ; ;~ While 1 ;~ Sleep(100) ;~ $msg2 = GUIGetMsg() ;~ Select ;~ Case $msg2 = $GUI_EVENT_CLOSE ;~ MsgBox(0, "test", "test") ;~ GUISetState(@SW_DISABLE, $formGlobal) ;~ GUISetState(@SW_ENABLE, $formLink) ;~ GUISwitch($formLink) ;~ GUIDelete($formGlobal) ;~ Return ;~ EndSelect ;~ WEnd EndFunc ;==>globalSettingsGUI Func formGlobalClose() MsgBox(0, "test", "test") GUISetState(@SW_DISABLE, $formGlobal) GUISetState(@SW_ENABLE, $formLink) GUISwitch($formLink) GUIDelete($formGlobal) EndFunc ;==>formGlobalClose Func formGlobalMaximize() EndFunc ;==>formGlobalMaximize Func formGlobalMinimize() EndFunc ;==>formGlobalMinimize Func formGlobalRestore() EndFunc ;==>formGlobalRestore Func btnGlobalSaveSettingsClick() MsgBox(0, "test", "test") GUISetState(@SW_DISABLE, $formGlobal) GUISetState(@SW_ENABLE, $formLink) GUISwitch($formLink) GUIDelete($formGlobal) EndFunc ;==>btnGlobalSaveSettingsClick GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
FrozenTeeth Posted March 24, 2010 Author Share Posted March 24, 2010 Thanks for the quick reply, and the quick fix. I now see what I was doing wrong. Thanks again. Great to see helpful people. Keep it up! Link to comment Share on other sites More sharing options...
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