Jump to content
Sign in to follow this  
bluespirit

How do you stop MsgBox losing focus

Recommended Posts

bluespirit

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
bluespirit

That's exactly the sort of thing I was looking for. Thanks for that.

J

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.