From ea99e0c03eeb89825f7e42922429a4abeeb654ed Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sat, 10 May 2014 23:28:53 -0400 Subject: [PATCH] Added limited message-box support for Windows Phone 8.1 The Windows Phone 8.1 'MessageDialog' API only seems to support two buttons, despite the documentation for such mentioning support for three. Trying to use three or more buttons leads to an exception being thrown. As such, any attempt to use more than two buttons via SDL_ShowMessageBox (on Windows Phone 8.1) will lead to no message box getting shown, and the call returning an error. The Win32 MessageBox and dialog APIs are not available in WinRT apps, to note. More extensive message dialog support might be available at some point, if and when XAML support is more fully fleshed-out. I'm not certain of this, though. --- src/video/winrt/SDL_winrtmessagebox.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/video/winrt/SDL_winrtmessagebox.cpp b/src/video/winrt/SDL_winrtmessagebox.cpp index 71d9911dc..4af17187a 100644 --- a/src/video/winrt/SDL_winrtmessagebox.cpp +++ b/src/video/winrt/SDL_winrtmessagebox.cpp @@ -46,7 +46,7 @@ WINRT_UTF8ToPlatformString(const char * str) extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8) /* Sadly, Windows Phone 8 doesn't include the MessageDialog class that * Windows 8.x/RT does, even though MSDN's reference documentation for * Windows Phone 8 mentions it. @@ -54,12 +54,21 @@ WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) * The .NET runtime on Windows Phone 8 does, however, include a * MessageBox class. Perhaps this could be called, somehow? */ - return SDL_SetError("SDL_messagebox support is not available for Windows Phone"); + return SDL_SetError("SDL_messagebox support is not available for Windows Phone 8.0"); #else SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (messageboxdata->numbuttons > 3) { - return SDL_SetError("WinRT's MessageDialog only supports 3 buttons, at most. %d were requested.", messageboxdata->numbuttons); +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + const int maxbuttons = 3; + const char * platform = "Windows Phone 8.1+"; +#else + const int maxbuttons = 3; + const char * platform = "Windows 8.x"; +#endif + + if (messageboxdata->numbuttons > maxbuttons) { + return SDL_SetError("WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.", + maxbuttons, platform, messageboxdata->numbuttons); } /* Build a MessageDialog object and its buttons */