Sign in to follow this  
Followers 0
Richard

msgbox

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Just use all parameters for MsgBox(). In your case, for e.g. OK:

MsgBox(0, "GUI Event", "You pressed OK!", 0, $a)

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0