21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_WINRT
27 #include "../../core/windows/SDL_windows.h"
32 #include <windows.ui.popups.h>
33 using namespace Platform;
34 using namespace Windows::Foundation;
35 using namespace Windows::UI::Popups;
38 WINRT_UTF8ToPlatformString(
const char * str)
41 String ^ rtstr =
ref new String(wstr);
49 #if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8)
57 return SDL_SetError(
"SDL_messagebox support is not available for Windows Phone 8.0");
61 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
62 const int maxbuttons = 2;
63 const char * platform =
"Windows Phone 8.1+";
65 const int maxbuttons = 3;
66 const char * platform =
"Windows 8.x";
70 return SDL_SetError(
"WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.",
71 maxbuttons, platform, messageboxdata->
numbuttons);
75 MessageDialog ^ dialog =
ref new MessageDialog(WINRT_UTF8ToPlatformString(messageboxdata->
message));
76 dialog->Title = WINRT_UTF8ToPlatformString(messageboxdata->
title);
79 button->Id = safe_cast<IntPtr>(
i);
80 dialog->Commands->Append(
button);
82 dialog->CancelCommandIndex =
i;
85 dialog->DefaultCommandIndex =
i;
91 auto operation = dialog->ShowAsync();
92 while (operation->Status == Windows::Foundation::AsyncStatus::Started) {
97 if (operation->Status != Windows::Foundation::AsyncStatus::Completed) {
98 return SDL_SetError(
"An unknown error occurred in displaying the WinRT MessageDialog");
101 IntPtr results = safe_cast<IntPtr>(operation->GetResults()->Id);
102 int clicked_index = results.ToInt32();