#pragma section-numbers off #pragma camelcase off || DRAFT|| ##*^*^*^*^*See http://wiki.libsdl.org/moin.cgi/SGFunctions for details on editing this page*^*^*^*^* = SDL_ShowMessageBox = Use this function to create a modal message box. <> == Syntax == {{{#!highlight cpp int SDL_ShowMessageBox(const SDL_MessageBoxData* messageboxdata, int* buttonid) }}} == Function 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|| == Return Value == Returns 0 on success or a negative error code on failure; call [[SDL_GetError]]() for more information. == Code Examples == {{{#!highlight cpp #include "SDL.h" int main(int argc, char *argv[]) { const SDL_MessageBoxButtonData buttons[] = { { /* .flags, .buttonid, .text */ 0, 0, "no" }, { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "yes" }, { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "cancel" }, }; const SDL_MessageBoxColorScheme colorScheme = { { /* .colors (.r, .g, .b) */ /* [SDL_MESSAGEBOX_COLOR_BACKGROUND] */ { 255, 0, 0 }, /* [SDL_MESSAGEBOX_COLOR_TEXT] */ { 0, 255, 0 }, /* [SDL_MESSAGEBOX_COLOR_BUTTON_BORDER] */ { 255, 255, 0 }, /* [SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND] */ { 0, 0, 255 }, /* [SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED] */ { 255, 0, 255 } } }; const SDL_MessageBoxData messageboxdata = { SDL_MESSAGEBOX_INFORMATION, /* .flags */ NULL, /* .window */ "example message box", /* .title */ "select a button", /* .message */ SDL_arraysize(buttons), /* .numbuttons */ buttons, /* .buttons */ &colorScheme /* .colorScheme */ }; int buttonid; if (SDL_ShowMessageBox(&messageboxdata, &buttonid) < 0) { SDL_Log("error displaying message box"); return 1; } if (buttonid == -1) { SDL_Log("no selection"); } else { SDL_Log("selection was %s", buttons[buttonid].text); } return 0; } }}} ##Leave this section as-is unless you have a code example to put in. In that case, replace You can add your code example here with your code example following the Style Guide instructions. Leave the rest of the markup alone and delete this comment. == Remarks == 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. == Version == This function is available since SDL 2.0.0. == Related Functions == .[[SDL_ShowSimpleMessageBox]] ---- [[CategoryAPI]], [[CategoryVideo]] ##See the Style Guide for instructions on editing the footer.