Jump to content

Can someone point out why the Second window will not close


Noddle
 Share

Recommended Posts

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

#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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...