messagebox
Displays a message box dialog.
Syntax
messagebox(text: string, caption: string, flags: number) -> numberParameters
| Parameter | Type | Description |
|---|---|---|
text | string | The message text |
caption | string | The window title |
flags | number | Button and icon flags accepted by the Windows MessageBoxA API |
Returns
| Type | Description |
|---|---|
number | The button pressed by the user |
Description
messagebox displays a Windows-style message box with customizable buttons and icons.
See Microsoft's MessageBoxA documentation for the complete flag and return-value reference.
Common Flags
| Flag | Description |
|---|---|
0 | OK button |
1 | OK + Cancel |
4 | Yes + No |
16 | Error icon |
32 | Question icon |
48 | Warning icon |
64 | Info icon |
Return Values
| Value | Description |
|---|---|
1 | OK |
2 | Cancel |
6 | Yes |
7 | No |
Example
-- Simple message
messagebox("Hello!", "Greeting", 0)
-- Confirmation dialog
local result = messagebox("Are you sure?", "Confirm", 4 + 32)
if result == 6 then
print("User clicked Yes")
else
print("User clicked No")
end
-- Warning message
messagebox("Something went wrong!", "Warning", 0 + 48)Notes
- Flags can be combined with addition
- This is a yielding function