al_show_native_message_box(3alleg5)
π al_show_native_message_box π
okay bestie, so this one is literally from the Allegro 5 API and it's giving "pop up a real, actual, native GUI message box" energy and honestly? iconic. β¨
πΈ NAME πΈ
al_show_native_message_box β the Allegro 5 API function that pops a native message box at the user like "hey. read this. π«Ά"
π¦ SYNOPSIS π¦
#include <allegro5/allegro_native_dialog.h>
int al_show_native_message_box(ALLEGRO_DISPLAY *display,
char const *title, char const *heading, char const *text,
char const *buttons, int flags)
β¨ DESCRIPTION β¨
So like, this shows a native GUI message box. It's the real deal, the operating system's own dialog, not some fake little in-game rectangle. π
You'd use it for stuff like showing an error message if creating your initial display fails. And here's the cute part: the display can be NULL, but if you do pass one, that display gets treated as the parent if possible. πΌ
By default the message box has a single "OK" button and rocks the style that informative dialog boxes usually have on the native system. Very demure, very mindful. But if the buttons parameter is not NULL, you can instead write the button text yourself in a string, with the buttons separated by a vertical bar (|). slay. π
Note: the buttons parameter is currently unimplemented on Windows. π Not me finding out the hard way. It's just not there yet, bestie.
The flags you can use are:
ALLEGRO_MESSAGEBOX_WARNβ the message is a warning. This may cause a different icon (or other effects). β οΈALLEGRO_MESSAGEBOX_ERRORβ the message is an error. πALLEGRO_MESSAGEBOX_QUESTIONβ the message is a question. π€ALLEGRO_MESSAGEBOX_OK_CANCELβ display a cancel button alongside the"OK"button. Ignored ifbuttonsis notNULL.ALLEGRO_MESSAGEBOX_YES_NOβ display Yes/No buttons instead of the"OK"button. Ignored ifbuttonsis notNULL.
And the wildest part: al_show_native_message_box(3alleg5) may be called without Allegro being installed. Not me being able to yell for help before Allegro even wakes up π β this is useful to report an error during initialisation of Allegro itself. Periodt.
π Returns π
0if the dialog window was closed without activating a button.1if the OK or Yes button was pressed.2if the Cancel or No button was pressed.
If buttons is not NULL, the number of the pressed button is returned, starting with 1.
All of the remaining parameters must not be NULL. fr fr, don't test it. π
If a message box could not be created then this returns 0, as if the window was dismissed without activating a button. So 0 is doing double duty, iykyk. π
π Example π
int button = al_show_native_message_box(
display,
"Warning",
"Are you sure?",
"If you click yes then you are confirming that \"Yes\" "
"is your response to the query which you have "
"generated by the action you took to open this "
"message box.",
NULL,
ALLEGRO_MESSAGEBOX_YES_NO
);
okay that's the whole vibe. go forth and pop your message boxes, bestie. main character energy only. π β¨
signing off with love β this was the Allegro reference manual's take on `al_show_native_message_box(3alleg5)**, straight from the source, no cap. ππ¦πΈ
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms