Page 1 of 1

Strange MessageBox Behavior

Posted: 02 Feb 2020, 04:40
by scriptor2016
hello, I was wondering why the "esc" hotkey works in this script:

Code: Select all

1::
MsgBox, 5, MyMsgBox, Hello
Return

esc::
WinClose, MyMsgBox
Return
..but it does *not* work in this one:

Code: Select all

1::
MsgBox, 4, MyMsgBox, Hello
Return

esc::
WinClose, MyMsgBox
Return

Re: Strange MessageBox Behavior

Posted: 02 Feb 2020, 05:25
by gregster
In the case with the 4 option, the x (the Close button in the msgbox's titlebar) is disabled by the Windows system, and there is no Cancel button ("clicking the X is the same as pressing Cancel").

If there is no Cancel button, it can't be cancelled and WinClose, which just sends a WM_CLOSE message, can't override this requirement. The user is forced to choose yes or no.

Afaik, this is intentional and based on the behaviour of the underlying MessageBox function of the Windows system.

Re: Strange MessageBox Behavior

Posted: 03 Feb 2020, 10:18
by scriptor2016
yes, you're right - I hadn't noticed that the 'X' button is disabled on a MessageBox, 4.

That's odd, I wonder why it's like that - 4 cannot be closed, but 5 (and others) are able to be closed.

Oh well, thanks for clearing that up! I was scratching my head over that one on the weekend lol ;)