Page 1 of 1

[a103] - MsgBox [BUG]

Posted: 24 Jun 2019, 10:43
by _3D_
The BUG

Code: Select all

res:= MsgBox("Press Esc!")
MsgBox("User pressed : " res)
User pressed "Esc" but MsgBox return "OK". Actually in this case MsgBox return only "OK".
In this case MsgBox must return "" (nothing) when pressed "Esc" or clicked on "X".

Code: Select all

res:= MsgBox("Press Esc!",,"OC")
MsgBox("User pressed : " res)
In this case MsgBox return "OK" only if user pressed "OK" and "Cancel" when "Esc" or "X".

Suggestion:
If MsgBox closed with "X" then return ""
If MsgBox have option "Cancel" then when pressed "Esc" return "Cancel" else return "".

Best: when "Esc" or "X" return ""

Re: [a103] - MsgBox [BUG]  Topic is solved

Posted: 24 Jun 2019, 10:48
by Helgef
It is documented behaviour,
msgbox wrote:The Close button (in MsgBox's title bar): Since the MsgBox window is a built-in feature of the operating system, its X button is enabled only when certain buttons are present. If there is only an OK button, clicking the X button is the same as pressing OK. Otherwise, the X button is disabled unless there is a Cancel button, in which case clicking the X is the same as pressing Cancel.

Re: [a103] - MsgBox [BUG]

Posted: 24 Jun 2019, 10:59
by _3D_
In other words using MsgBox without options is not recommended because no deference in answers.