Message box

Syntax

int mes[-](text [caption] [style])

 

Parameters

text - message text. Can be string or numeric. Use F-string to insert variables. Supports links.

caption - message box title. Default: "" ("QM Message").

style - message box style. Read in Remarks. Default: "" (OK button only).

 

Options:

- on 'Cancel' and 'No' end macro. Also, ends macro if there is only OK button.

 

Remarks

Shows standard message box dialog. Returns the first character of selected button's name in English ('O' for OK, 'Y' for Yes, etc).

 

style can be string consisting of one or more characters or substrings. Syntax:

 

"[O|OC|YN|YNC|ARI|RC|CTE][1|2|3][?|!|x|i|q|v][s][a|n][t]"

 

 O, OC, YN, YNC, ARI, RC, CTE - buttons. Default: OK.

O OK
OC OK Cancel
YN Yes No
YNC Yes No Cancel
ARI Abort Retry Ignore
RC Retry Cancel
CTE Cancel Try-Again Continue

 1, 2, 3 - default button. Default: 1.

 ?, !, x, i, q, v - icon. Default: no icon.

? question (question-mark icon).
! warning (exclamation-point icon).
x error (stop-sign icon).
i information (i in a circle icon).
q QM icon. In exe - exe icon.
v On Vista and later - shield icon. On older Windows - silent warning icon (same as !s). Added in QM 2.2.0.

 a - always activate message box window.

 n - prevent activating message box window. See also RtOptions.

 t - topmost (always on top of other windows). Use only if owner window is specified; else message box is topmost by default.

 s - silent. Don't play sounds.

 

style also can be an integer - MB_x flags used with MessageBox.

 

style also can be a variable of type MES.

 

type MES ~style x y timeout default hwndowner

 

style - message box style. Same as style parameter of mes.

x and y - message box coordinates. Changed are only if nonzero. If negative - relative to the screen right and/or top edge.

timeout - max time (seconds) to show the message box.

default - button to choose (e.g., 'C'), or some other value to return on timeout. Values 1-15 are mapped to button characters that match Windows API standard button constants, eg IDOK to 'O', IDCANCEL to 'C'.

hwndowner - owner window handle. The owner window, if belongs to the same thread, will be disabled.

 

You can set only members that you need.

 

Examples

mes- "Click OK button"

mes F"Missing file {path}." "Error" "x"

if(mes("Save?" "" "YN?") != 'Y') ret

MES m
m.style="YNCn"
m.x=100
m.y=1
m.timeout=15
m.default='C'
int i=mes("message" "title" m)