Richard Posted December 23, 2009 Share Posted December 23, 2009 Isn't it so that a messagebox should block of all other window manipulations until closed? In the following example code the button can be clicked while the messagebox is present, creating several instances of the msgbox. How can this be avoided? #include <GUIConstantsEx.au3> $a = GUICreate("Hello World", 300, 200) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $b= GUICtrlCreateButton("OK", 70, 50, 60) $c = GUICtrlCreateButton("quit", 170, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg =$b MsgBox(0, "GUI Event", "You pressed OK!") Case $msg = $c MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
Mat Posted December 23, 2009 Share Posted December 23, 2009 It does block them... Instead they are sent to the queue, so when the MsgBox finishes it then executes the next. If you want to stop that the just disable the GUI while the MsgBox is showing: #include <GUIConstantsEx.au3> $a = GUICreate("Hello World", 300, 200) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $b = GUICtrlCreateButton("OK", 70, 50, 60) $c = GUICtrlCreateButton("quit", 170, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $b GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You pressed OK!") GUISetState(@SW_ENABLE) Case $msg = $c GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") GUISetState(@SW_ENABLE) ExitLoop Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") GUISetState(@SW_ENABLE) ExitLoop EndSelect WEnd Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Richard Posted December 23, 2009 Author Share Posted December 23, 2009 this seems to work too: msgbox(8192,"NOTICE",$sp[1]) It does block them... Instead they are sent to the queue, so when the MsgBox finishes it then executes the next. If you want to stop that the just disable the GUI while the MsgBox is showing: #include <GUIConstantsEx.au3> $a = GUICreate("Hello World", 300, 200) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $b = GUICtrlCreateButton("OK", 70, 50, 60) $c = GUICtrlCreateButton("quit", 170, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $b GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You pressed OK!") GUISetState(@SW_ENABLE) Case $msg = $c GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") GUISetState(@SW_ENABLE) ExitLoop Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") GUISetState(@SW_ENABLE) ExitLoop EndSelect WEnd Mat Link to comment Share on other sites More sharing options...
Richard Posted December 24, 2009 Author Share Posted December 24, 2009 With this code there is still a strange behaviour. When clicking OK on the first button, the window closes. Why? ------------------------------------------------------------------ It does block them... Instead they are sent to the queue, so when the MsgBox finishes it then executes the next. If you want to stop that the just disable the GUI while the MsgBox is showing: #include <GUIConstantsEx.au3> $a = GUICreate("Hello World", 300, 200) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $b = GUICtrlCreateButton("OK", 70, 50, 60) $c = GUICtrlCreateButton("quit", 170, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $b GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You pressed OK!") GUISetState(@SW_ENABLE) Case $msg = $c GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") GUISetState(@SW_ENABLE) ExitLoop Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_DISABLE) MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") GUISetState(@SW_ENABLE) ExitLoop EndSelect WEnd Mat Link to comment Share on other sites More sharing options...
trancexx Posted December 24, 2009 Share Posted December 24, 2009 Just use all parameters for MsgBox(). In your case, for e.g. OK: MsgBox(0, "GUI Event", "You pressed OK!", 0, $a) ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Posted December 24, 2009 Author Share Posted December 24, 2009 thanks, this solves the problem, also for inputbox Richard Just use all parameters for MsgBox(). In your case, for e.g. OK: MsgBox(0, "GUI Event", "You pressed OK!", 0, $a) 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