These functions are declared in the following header file. Link with allegro_dialog.

#include <allegro5/allegro_native_dialog.h>



Opaque handle to a native file dialog.



Opaque handle to a text log window.


bool al_init_native_dialog_addon(void)

Initialise the native dialog addon.

Returns true on success, false on error.

Since: 5.0.9, 5.1.0

Note: Prior to Allegro 5.1.0 native dialog functions could be called without explicit initialisation, but that is now deprecated. Future functionality may require explicit initialisation. An exception is al_show_native_message_box, which may be useful to show an error message if Allegro fails to initialise.

See also: al_shutdown_native_dialog_addon


void al_shutdown_native_dialog_addon(void)

Shut down the native dialog addon.

Since: 5.0.9, 5.1.5

See also: al_init_native_dialog_addon


ALLEGRO_FILECHOOSER *al_create_native_file_dialog(
   char const *initial_path,
   char const *title,
   char const *patterns,
   int mode)

Creates a new native file dialog. You should only have one such dialog opened at a time.


Possible flags for the 'flags' parameter are:

If supported by the native dialog, it will not allow entering new names, but just allow existing files to be selected. Else it is ignored.
If the native dialog system has a different dialog for saving (for example one which allows creating new directories), it is used. Else ignored.
If there is support for a separate dialog to select a folder instead of a file, it will be used.
If a different dialog is available for selecting pictures, it is used. Else ignored.
If the platform supports it, also hidden files will be shown.
If supported, allow selecting multiple files.


A handle to the dialog which you can pass to al_show_native_file_dialog to display it, and from which you then can query the results. When you are done, call al_destroy_native_file_dialog on it.

If a dialog window could not be created then this function returns NULL.


bool al_show_native_file_dialog(ALLEGRO_DISPLAY *display,

Show the dialog window. The display may be NULL, otherwise the given display is treated as the parent if possible.

This function blocks the calling thread until it returns, so you may want to spawn a thread with al_create_thread and call it from inside that thread.

Returns true on success, false on failure.


int al_get_native_file_dialog_count(const ALLEGRO_FILECHOOSER *dialog)

Returns the number of files selected, or 0 if the dialog was cancelled.


const char *al_get_native_file_dialog_path(
   const ALLEGRO_FILECHOOSER *dialog, size_t i)

Returns one of the selected paths.


void al_destroy_native_file_dialog(ALLEGRO_FILECHOOSER *dialog)

Frees up all resources used by the file dialog.


int al_show_native_message_box(ALLEGRO_DISPLAY *display,
   char const *title, char const *heading, char const *text,
   char const *buttons, int flags)

Show a native GUI message box. This can be used for example to display an error message if creation of an initial display fails. The display may be NULL, otherwise the given display is treated as the parent if possible.

The message box will have a single "OK" button and use the style informative dialog boxes usually have on the native system. If the buttons parameter is not NULL, you can instead specify the button text in a string, with buttons separated by a vertical bar (|).

The message is a warning. This may cause a different icon (or other effects).
The message is an error.
The message is a question.
Instead of the "OK" button also display a cancel button. Ignored if buttons is not NULL.
Instead of the "OK" button display Yes/No buttons. Ignored if buttons is not NULL.

al_show_native_message_box may be called without Allegro being installed. This is useful to report an error to initialise Allegro itself.


If buttons is not NULL, the number of the pressed button is returned, starting with 1.

If a message box could not be created then this returns 0, as if the window was dismissed without activating a button.


  button = al_show_native_message_box(
     "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.",


ALLEGRO_TEXTLOG *al_open_native_text_log(char const *title, int flags)

Opens a window to which you can append log messages with al_append_native_text_log. This can be useful for debugging if you don't want to depend on a console being available.

Use al_close_native_text_log to close the window again.

The flags available are:


Prevent the window from having a close button. Otherwise if the close button is pressed an event is generated; see al_get_native_text_log_event_source.


Use a monospace font to display the text.

Returns NULL if there was an error opening the window, or if text log windows are not implemented on the platform.

See also: al_append_native_text_log, al_close_native_text_log


void al_close_native_text_log(ALLEGRO_TEXTLOG *textlog)

Closes a message log window opened with al_open_native_text_log earlier.

Does nothing if passed NULL.

See also: al_open_native_text_log


void al_append_native_text_log(ALLEGRO_TEXTLOG *textlog,
   char const *format, ...)

Appends a line of text to the message log window and scrolls to the bottom (if the line would not be visible otherwise). This works like printf. A line is continued until you add a newline character.

If the window is NULL then this function will fall back to calling printf. This makes it convenient to support logging to a window or a terminal.


ALLEGRO_EVENT_SOURCE *al_get_native_text_log_event_source(
   ALLEGRO_TEXTLOG *textlog)

Get an event source for a text log window. The possible events are:

The window was requested to be closed, either by pressing the close button or pressing Escape on the keyboard. The user.data1 field will hold a pointer to the ALLEGRO_TEXTLOG which generated the event. The user.data2 field will be 1 if the event was generated as a result of a key press; otherwise it will be zero.


uint32_t al_get_allegro_native_dialog_version(void)

Returns the (compiled) version of the addon, in the same format as al_get_allegro_version.

Allegro version 5.0.10 (GIT) - Last updated: 2013-06-16 03:02:21 UTC