Student_coder Posted May 31, 2016 Share Posted May 31, 2016 (edited) Hi everyone, Am having 3 forms - 1 main_form, a_form and b_form. All of them have close button. In the main_form there is two button besides close button - butn1 and butn2. If we select butn1 a_form will come else if butn2 b_form will come. When I close the main _frame everything will close which is fine. If we click on close button in a_form and b_form then it will close the script which is not fine. If we close a_form or b_form, a_form or b_form should close and main_form should come but it's not happening. I have tried using while loop and switch which effects the whole code. Is there any other way to do this?? Quote while 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $delete_frm) GUISetState($GUI_ENABLE, $Form1) GUISetState(@SW_RESTORE, $Form1) ExitLoop Edited May 31, 2016 by Student_coder Link to comment Share on other sites More sharing options...
water Posted May 31, 2016 Share Posted May 31, 2016 The wiki has a tutorial on how to handle multiple GUIs: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AutoBert Posted May 31, 2016 Share Posted May 31, 2016 as i already told (pm) post a runable (reproducer) script showing the issue(s). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 31, 2016 Moderators Share Posted May 31, 2016 Student_coder, Quote as i already told (pm) And as I have already told you via PM, in future do NOT PM other forum members asking for help. 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 Link to comment Share on other sites More sharing options...
Annonyreeder Posted June 2, 2016 Share Posted June 2, 2016 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $GUI2 global $GUI = GUICreate("Main GUI", 100, 150, 0, 0) ;Create Main GUI GUISetOnEvent($GUI_EVENT_CLOSE, "on_exit") GUICtrlCreateButton("Exit", 0, 0,100,50) ;Closing GUI go to on_exit function GUICtrlSetOnEvent(-1, "on_exit") GUICtrlCreateButton("GUI2", 0,50,100,50) GUICtrlSetOnEvent(-1, "GUI2") GUICtrlCreateButton("GUI3", 0,100,100,50) GUICtrlSetOnEvent(-1, "GUI3") GUISetState(@SW_SHOW) while 1 sleep(5) WEnd func GUI2() GUISetState(@SW_HIDE) global $GUI2 = GUICreate("GUI2", 100, 150, 0, 0) ;Create Second GUI GUISetOnEvent($GUI_EVENT_CLOSE, "Close_Settings") ;When closing GUI go to Close settings GUICtrlCreateButton("Close GUI", 0, 0, 100,50) GUICtrlSetOnEvent(-1, "Close_Settings") ;Closing button go to close settings GUISetState(@SW_SHOW) EndFunc func GUI3() GUISetState(@SW_HIDE) global $GUI3 = GUICreate("GUI3", 100, 150, 0, 0) ;Create Third GUI GUISetOnEvent($GUI_EVENT_CLOSE, "Close_Settings") ;When closing GUI go to Close Settings GUICtrlCreateButton("Close GUI", 0, 0, 100,50) GUICtrlSetOnEvent(-1, "Close_Settings") ;Closing button go to close settings GUISetState(@SW_SHOW) EndFunc func Close_Settings() if WinExists("GUI2") then ;If GUI2 existss delete it GUISetState(@SW_SHOW, $GUI) GUIDelete($GUI2) ;otherwise Close GUI3 Else GUISetState(@SW_SHOW, $GUI) GUIDelete($GUI3) EndIf EndFunc func on_exit() Exit EndFunc Is this what you're trying to do? Sorry for messy code, I'm not very tidy lol. Edit: Just realized what you wanted to do, Edited code. Dunno if this is the 'Best' Way to do it however it is how I would do it lol. Edit2: Lol sorry after reading your question AGAIN, I think I understand what you are trying to do. Try this code. I will leave both here and if I have not addressed your problem hopefully you can adapt the code to fit your needs expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $GUI2 global $GUI = GUICreate("Main GUI", 100, 150, 0, 0) ;Create Main GUI GUISetOnEvent($GUI_EVENT_CLOSE, "on_exit") GUICtrlCreateButton("Exit", 0, 0,100,50) ;Closing GUI go to on_exit function GUICtrlSetOnEvent(-1, "on_exit") GUICtrlCreateButton("GUI2", 0,50,100,50) GUICtrlSetOnEvent(-1, "GUI2") GUICtrlCreateButton("GUI3", 0,100,100,50) GUICtrlSetOnEvent(-1, "GUI3") GUISetState(@SW_SHOW) while 1 sleep(5) WEnd func GUI2() global $GUI2 = GUICreate("GUI2", 100, 150, 115, 0) ;Create Second GUI GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI2") ;When closing GUI go to Close settings GUICtrlCreateLabel("GUI2", 0, 50) GUICtrlCreateButton("Close GUI", 0, 0, 100,50) GUICtrlSetOnEvent(-1, "CloseGUI2") ;Closing button go to close settings GUISetState(@SW_SHOW) EndFunc func GUI3() global $GUI3 = GUICreate("GUI3", 100, 150, 230, 0) ;Create Third GUI GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI3") ;When closing GUI go to Close Settings GUICtrlCreateLabel("GUI3", 0, 50) GUICtrlCreateButton("Close GUI", 0, 0, 100,50) GUICtrlSetOnEvent(-1, "CloseGUI3") ;Closing button go to close settings GUISetState(@SW_SHOW) EndFunc func CloseGUI2() GUIDelete($GUI2) EndFunc func CloseGUI3() GUIDelete($GUI3) EndFunc func on_exit() Exit EndFunc Again sorry for being messy, Its just how I work Edited June 2, 2016 by Annonyreeder 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