SDL_messagebox.h File Reference
`#include "SDL_stdinc.h"`
`#include "SDL_video.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_messagebox.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDL_MessageBoxButtonData
struct | SDL_MessageBoxColor
struct | SDL_MessageBoxColorScheme
struct | SDL_MessageBoxData

## Enumerations

enum | SDL_MessageBoxFlags { SDL_MESSAGEBOX_ERROR = 0x00000010 , SDL_MESSAGEBOX_WARNING = 0x00000020 , SDL_MESSAGEBOX_INFORMATION = 0x00000040 , SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080 , SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 }
enum | SDL_MessageBoxButtonFlags { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001 , SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 }
enum | SDL_MessageBoxColorType { SDL_MESSAGEBOX_COLOR_BACKGROUND , SDL_MESSAGEBOX_COLOR_TEXT , SDL_MESSAGEBOX_COLOR_BUTTON_BORDER , SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND , SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED , SDL_MESSAGEBOX_COLOR_MAX }

## Functions

int | SDL_ShowMessageBox (const SDL_MessageBoxData *messageboxdata, int *buttonid)
int | SDL_ShowSimpleMessageBox (Uint32 flags, const char *title, const char *message, SDL_Window *window)

## Enumeration Type Documentation

## SDL_MessageBoxButtonFlags

enum SDL_MessageBoxButtonFlags

Flags for SDL_MessageBoxButtonData.

Enumerator
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT | Marks the default button when return is hit
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT | Marks the default button when escape is hit

Definition at line 51 of file SDL_messagebox.h.

{
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */
} SDL_MessageBoxButtonFlags;
SDL_MessageBoxButtonFlags
SDL_MessageBoxButtonFlags
Definition SDL_messagebox.h:52
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
@ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
Definition SDL_messagebox.h:53
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
@ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
Definition SDL_messagebox.h:54

## SDL_MessageBoxColorType

enum SDL_MessageBoxColorType

Enumerator
SDL_MESSAGEBOX_COLOR_BACKGROUND |
SDL_MESSAGEBOX_COLOR_TEXT |
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER |
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND |
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED |
SDL_MESSAGEBOX_COLOR_MAX |

Definition at line 75 of file SDL_messagebox.h.

{
SDL_MESSAGEBOX_COLOR_BACKGROUND,
SDL_MESSAGEBOX_COLOR_TEXT,
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
SDL_MESSAGEBOX_COLOR_MAX
} SDL_MessageBoxColorType;
SDL_MessageBoxColorType
SDL_MessageBoxColorType
Definition SDL_messagebox.h:76
SDL_MESSAGEBOX_COLOR_MAX
@ SDL_MESSAGEBOX_COLOR_MAX
Definition SDL_messagebox.h:82
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND
@ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND
Definition SDL_messagebox.h:80
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED
@ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED
Definition SDL_messagebox.h:81
SDL_MESSAGEBOX_COLOR_BACKGROUND
@ SDL_MESSAGEBOX_COLOR_BACKGROUND
Definition SDL_messagebox.h:77
SDL_MESSAGEBOX_COLOR_TEXT
@ SDL_MESSAGEBOX_COLOR_TEXT
Definition SDL_messagebox.h:78
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER
@ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER
Definition SDL_messagebox.h:79

## SDL_MessageBoxFlags

enum SDL_MessageBoxFlags

SDL_MessageBox flags.

If supported will display warning icon, etc.

Enumerator
SDL_MESSAGEBOX_ERROR | error dialog
SDL_MESSAGEBOX_WARNING | warning dialog
SDL_MESSAGEBOX_INFORMATION | informational dialog
SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT | buttons placed left to right
SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT | buttons placed right to left

Definition at line 39 of file SDL_messagebox.h.

{
SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */
SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, /**< buttons placed left to right */
SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 /**< buttons placed right to left */
} SDL_MessageBoxFlags;
SDL_MessageBoxFlags
SDL_MessageBoxFlags
Definition SDL_messagebox.h:40
SDL_MESSAGEBOX_ERROR
@ SDL_MESSAGEBOX_ERROR
Definition SDL_messagebox.h:41
SDL_MESSAGEBOX_WARNING
@ SDL_MESSAGEBOX_WARNING
Definition SDL_messagebox.h:42
SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
@ SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
Definition SDL_messagebox.h:45
SDL_MESSAGEBOX_INFORMATION
@ SDL_MESSAGEBOX_INFORMATION
Definition SDL_messagebox.h:43
SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT
@ SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT
Definition SDL_messagebox.h:44

## Function Documentation

## SDL_ShowMessageBox()

int SDL_ShowMessageBox | ( | const SDL_MessageBoxData * | messageboxdata,
|  | int * | buttonid )

extern

Create a modal message box.

If your needs aren't complex, it might be easier to use SDL_ShowSimpleMessageBox.

This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.

This function may be called at any time, even before SDL_Init(). This makes it useful for reporting errors like a failure to create a renderer or OpenGL context.

On X11, SDL rolls its own dialog box with X11 primitives instead of a formal toolkit like GTK+ or Qt.

Note that if SDL_Init() would fail because there isn't any available video target, this function is likely to fail for the same reasons. If this is a concern, check the return value from this function and fall back to writing to stderr if you can.

Parameters

  messageboxdata | the SDL_MessageBoxData structure with title, text and other options.
  buttonid | the pointer to which user id of hit button should be copied.

Returns
  0 on success or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_ShowSimpleMessageBox

## SDL_ShowSimpleMessageBox()

int SDL_ShowSimpleMessageBox | ( | Uint32 | flags,
|  | const char * | title,
|  | const char * | message,
|  | SDL_Window * | window )

extern

Display a simple modal message box.

If your needs aren't complex, this function is preferred over SDL_ShowMessageBox.

flags may be any of the following:

- SDL_MESSAGEBOX_ERROR: error dialog
- SDL_MESSAGEBOX_WARNING: warning dialog
- SDL_MESSAGEBOX_INFORMATION: informational dialog

This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.

This function may be called at any time, even before SDL_Init(). This makes it useful for reporting errors like a failure to create a renderer or OpenGL context.

On X11, SDL rolls its own dialog box with X11 primitives instead of a formal toolkit like GTK+ or Qt.

Note that if SDL_Init() would fail because there isn't any available video target, this function is likely to fail for the same reasons. If this is a concern, check the return value from this function and fall back to writing to stderr if you can.

Parameters

  flags | an SDL_MessageBoxFlags value.
  title | UTF-8 title text.
  message | UTF-8 message text.
  window | the parent window, or NULL for no parent.

Returns
  0 on success or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_ShowMessageBox