Noddle Posted March 8, 2014 Share Posted March 8, 2014 Hi, Could someone have a look over my code to see where I'm making my mistake, the second window will not close for some reason. Thanks, Nigel expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("Test", 345, 441, (@DesktopWidth /2 ) - 170, 139), $Form2 = 999 GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") $_PressedButtonX = GUICtrlCreateButton("Press Button", 32, 384, 273, 33) GUICtrlSetOnEvent(-1, "_PressedButton") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Exit Func _PressedButton() GUICtrlSetState($_PressedButtonX, $GUI_DISABLE) _GetDetails() EndFunc Func _GetDetails() GUISetState(@SW_DISABLE, $Form1) _BuildForm2() EndFunc Func _BuildForm2() ; Opt("GUIOnEventMode", 1) $Form2 = GUICreate("Test2", 350, 291, (@DesktopWidth /2 ) - 170, (@DesktopHeight / 2)-153) GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit2") $ButtonX = GUICtrlCreateButton("Finished / Save", 96, 248, 185, 25) GUICtrlSetOnEvent(-1, "OnExit2") WinSetOnTop("Test2", "", 1) GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd EndFunc Func OnExit() GUIDelete($Form1) Exit EndFunc Func OnExit2() beep () GUIDelete($Form2) GUISetState(@SW_ENABLE, $Form1) WinSetOnTop("Test", "", 1) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2014 Moderators Share Posted March 8, 2014 Noddle,Remove the While...WEnd loop from the _BuildForm2 function. You should only ever have the one idle loop in an OnEvent script as you cannot run a new function if you have not returned from the previous one - the Interrupting a running function tutorial in the Wiki explains this in detail. 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...
Noddle Posted March 8, 2014 Author Share Posted March 8, 2014 Noddle, Remove the While...WEnd loop from the _BuildForm2 function. You should only ever have the one idle loop in an OnEvent script as you cannot run a new function if you have not returned from the previous one - the Interrupting a running function tutorial in the Wiki explains this in detail. M23 Thank you for that, I don't use a lot of OnEvent coding, never had that when I started coding a long time ago, Z80 ASM, Basic, Pascal, Cobol, etc.. Nigel 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