CMJ Posted December 22, 2010 Share Posted December 22, 2010 Can anyone tell me why the buttons on the second GUI will not work in the following code? What am I missing here? Thanks in advance, cj expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUICoordMode", 2) Global $GUI1, $GUI2, $hChooseOK, $hChooseCancel, $hChooseOK2, $hChooseCancel2 GUI1() Func GUI1() $GUI1 = GUICreate("Number 1", 275, 175, -1, -1, BitOR($WS_CHILD, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), Default) $hChooseOK = GUICtrlCreateButton("Ok", -1, 25, 85, 25) GUICtrlSetOnEvent(-1, 'GUI2') $hChooseCancel = GUICtrlCreateButton("Cancel", 10, -1, 85, 25) GUICtrlSetOnEvent(-1, 'Close') GUISetOnEvent($GUI_EVENT_CLOSE, 'Close') GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd EndFunc Func GUI2() GUIDelete($GUI1) $GUI2 = GUICreate("GUI Number 2", 275, 175, -1, -1, BitOR($WS_CHILD, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), Default) $hChooseOK2 = GUICtrlCreateButton("Close", -1, 25, 85, 25) GUICtrlSetOnEvent(-1, 'Close') $hChooseCancel2 = GUICtrlCreateButton("Cancel", 10, -1, 85, 25) GUICtrlSetOnEvent(-1, 'Close') GUISetOnEvent($GUI_EVENT_CLOSE, 'Close') GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd EndFunc Func Close() Exit EndFunc Link to comment Share on other sites More sharing options...
smashly Posted December 22, 2010 Share Posted December 22, 2010 hi, move your sleep outside the functions.expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUICoordMode", 2) Global $GUI1, $GUI2, $hChooseOK, $hChooseCancel, $hChooseOK2, $hChooseCancel2 GUI1() While 1 Sleep(1000) WEnd Func GUI1() $GUI1 = GUICreate("Number 1", 275, 175, -1, -1, BitOR($WS_CHILD, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), Default) $hChooseOK = GUICtrlCreateButton("Ok", -1, 25, 85, 25) GUICtrlSetOnEvent(-1, 'GUI2') $hChooseCancel = GUICtrlCreateButton("Cancel", 10, -1, 85, 25) GUICtrlSetOnEvent(-1, 'Close') GUISetOnEvent($GUI_EVENT_CLOSE, 'Close', $GUI1) GUISetState(@SW_SHOW, $GUI1) EndFunc Func GUI2() GUIDelete($GUI1) $GUI2 = GUICreate("GUI Number 2", 275, 175, -1, -1, BitOR($WS_CHILD, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), Default) $hChooseOK2 = GUICtrlCreateButton("Close", -1, 25, 85, 25) GUICtrlSetOnEvent(-1, 'Close') $hChooseCancel2 = GUICtrlCreateButton("Cancel", 10, -1, 85, 25) GUICtrlSetOnEvent(-1, 'Close') GUISetOnEvent($GUI_EVENT_CLOSE, 'Close', $GUI2) GUISetState(@SW_SHOW, $GUI2) EndFunc Func Close() Exit EndFunc Cheers Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted December 23, 2010 Share Posted December 23, 2010 Can anyone tell me why the buttons on the second GUI will not work in the following code? What am I missing here? Events are queued and run from first to last. You need to return from the function like smashly showed. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
CMJ Posted December 23, 2010 Author Share Posted December 23, 2010 Thank you both. That was what I needed. I knew it was something simple. Regards, cj 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