Jump to content

How do you stop MsgBox losing focus


Recommended Posts

Is there any way of stopping a message box from losing focus?

Although the MsgBox function will pause the running of a script, I can still click away from the message box and onto my main GUI window. Although the main window does not process any user input (i.e. mouse clicks) it saves them up and processes them when the message box is closed.

It would be great if it acted like most windows applications, i.e. when the main GUI window was clicked it, it flashes the message box and makes it active again.

J

Link to comment
Share on other sites

Like this?

#include <GuiConstants.au3>

$hGUI = GUICreate("Test GUI", 200, 100)

$button = GUICtrlCreateButton("Test", 50, 50, 60, 25)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
            _MsgBox(64, "Some title", "Some text", $hGUI)
    EndSwitch
WEnd

Func _MsgBox($sFlag = 0, $sTitle = "", $sText = "", $hWnd = 0)
    DllCall("user32.dll", "int", "MessageBox", "hwnd", $hWnd, "str", $sText, "str", $sTitle, "int", $sFlag)
EndFunc
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...