windows: dos2unix'd messagebox code, and (hopefully) fixed on MingW.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 28 Feb 2018 02:14:15 -0500
changeset 119109947d9f539e8
parent 11909 b2e68bf41993
child 11911 235c5929651c
windows: dos2unix'd messagebox code, and (hopefully) fixed on MingW.
src/video/windows/SDL_windowsmessagebox.c
src/video/windows/SDL_windowstaskdialog.h
     1.1 --- a/src/video/windows/SDL_windowsmessagebox.c	Wed Feb 28 01:54:22 2018 -0500
     1.2 +++ b/src/video/windows/SDL_windowsmessagebox.c	Wed Feb 28 02:14:15 2018 -0500
     1.3 @@ -341,7 +341,7 @@
     1.4      return dialog;
     1.5  }
     1.6  
     1.7 -/* This function is called if a Task Dialog is unsupported. */
     1.8 +/* This function is called if a Task Dialog is unsupported. */
     1.9  static int
    1.10  WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
    1.11  {
    1.12 @@ -492,119 +492,119 @@
    1.13      return 0;
    1.14  }
    1.15  
    1.16 -/* TaskDialogIndirect procedure
    1.17 - * This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK.
    1.18 - */
    1.19 -typedef HRESULT(FAR WINAPI *TASKDIALOGINDIRECTPROC)(_In_ const TASKDIALOGCONFIG *pTaskConfig, _Out_opt_ int *pnButton, _Out_opt_ int *pnRadioButton, _Out_opt_ BOOL *pfVerificationFlagChecked);
    1.20 -
    1.21 -int
    1.22 -WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
    1.23 -{
    1.24 -    HWND ParentWindow = NULL;
    1.25 -    wchar_t *wmessage;
    1.26 -    wchar_t *wtitle;
    1.27 -    TASKDIALOGCONFIG TaskConfig;
    1.28 -    TASKDIALOG_BUTTON *pButtons;
    1.29 -    TASKDIALOG_BUTTON *pButton;
    1.30 -    HMODULE hComctl32;
    1.31 -    TASKDIALOGINDIRECTPROC pfnTaskDialogIndirect;
    1.32 -    HRESULT hr;
    1.33 -    int nButton;
    1.34 -    int nCancelButton;
    1.35 -    int i;
    1.36 -
    1.37 -    /* If we cannot load comctl32.dll use the old messagebox! */
    1.38 -    hComctl32 = LoadLibrary(TEXT("Comctl32.dll"));
    1.39 -    if (hComctl32 == NULL) {
    1.40 -        return WIN_ShowOldMessageBox(messageboxdata,buttonid);
    1.41 -    }
    1.42 -    
    1.43 -    /* If TaskDialogIndirect doesn't exist use the old messagebox!
    1.44 -       This will fail prior to Windows Vista.
    1.45 -       The manifest file in the application may require targeting version 6 of comctl32.dll, even
    1.46 -       when we use LoadLibrary here!
    1.47 -       If you don't want to bother with manifests, put this #pragma in your app's source code somewhere:
    1.48 -       pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0'  processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    1.49 -     */
    1.50 -    pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC) GetProcAddress(hComctl32, "TaskDialogIndirect");
    1.51 -    if (pfnTaskDialogIndirect == NULL) {
    1.52 -        FreeLibrary(hComctl32);
    1.53 -        return WIN_ShowOldMessageBox(messageboxdata, buttonid);
    1.54 -    }
    1.55 -
    1.56 -    /* If we have a parent window, get the Instance and HWND for them
    1.57 -       so that our little dialog gets exclusive focus at all times. */
    1.58 -    if (messageboxdata->window) {
    1.59 -        ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd;
    1.60 -    }
    1.61 -
    1.62 -    wmessage = WIN_UTF8ToString(messageboxdata->message);
    1.63 -    wtitle = WIN_UTF8ToString(messageboxdata->title);
    1.64 -
    1.65 -    SDL_zero(TaskConfig);
    1.66 -    TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG);
    1.67 -    TaskConfig.hwndParent = ParentWindow;
    1.68 -    TaskConfig.dwFlags = TDF_SIZE_TO_CONTENT;
    1.69 -    TaskConfig.pszWindowTitle = wtitle;
    1.70 -    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
    1.71 -        TaskConfig.pszMainIcon = TD_ERROR_ICON;
    1.72 -    } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
    1.73 -        TaskConfig.pszMainIcon = TD_WARNING_ICON;
    1.74 -    } else if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) {
    1.75 -        TaskConfig.pszMainIcon = TD_INFORMATION_ICON;
    1.76 -    } else {
    1.77 -        TaskConfig.pszMainIcon = NULL;
    1.78 -    }
    1.79 -
    1.80 -    TaskConfig.pszContent = wmessage;
    1.81 -    TaskConfig.cButtons = messageboxdata->numbuttons;
    1.82 -    pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
    1.83 -    TaskConfig.nDefaultButton = 0;
    1.84 -    for (i = 0; i < messageboxdata->numbuttons; i++)
    1.85 -    {
    1.86 -        pButton = &pButtons[messageboxdata->numbuttons-1-i];
    1.87 -        if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
    1.88 -            nCancelButton = messageboxdata->buttons[i].buttonid;
    1.89 -            pButton->nButtonID = 2;
    1.90 -        } else {
    1.91 -            pButton->nButtonID = messageboxdata->buttons[i].buttonid + 1;
    1.92 -            if (pButton->nButtonID >= 2) {
    1.93 -                pButton->nButtonID++;
    1.94 -            }
    1.95 -        }
    1.96 -        pButton->pszButtonText = WIN_UTF8ToString(messageboxdata->buttons[i].text);
    1.97 -        if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
    1.98 -            TaskConfig.nDefaultButton = pButton->nButtonID;
    1.99 -        }
   1.100 -    }
   1.101 -    TaskConfig.pButtons = pButtons;
   1.102 -
   1.103 -    /* Show the Task Dialog */
   1.104 -    hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL);
   1.105 -
   1.106 -    /* Free everything */
   1.107 -    FreeLibrary(hComctl32);
   1.108 -    SDL_free(wmessage);
   1.109 -    SDL_free(wtitle);
   1.110 -    for (i = 0; i < messageboxdata->numbuttons; i++) {
   1.111 -        SDL_free((wchar_t *) pButtons[i].pszButtonText);
   1.112 -    }
   1.113 -    SDL_free(pButtons);
   1.114 -
   1.115 -    /* Check the Task Dialog was successful and give the result */
   1.116 -    if (SUCCEEDED(hr)) {
   1.117 -        if (nButton == 2) {
   1.118 -            *buttonid = nCancelButton;
   1.119 -        } else if (nButton > 2) {
   1.120 -            *buttonid = nButton-1-1;
   1.121 -        } else {
   1.122 -            *buttonid = nButton-1;
   1.123 -        }
   1.124 -        return 0;
   1.125 -    }
   1.126 -
   1.127 -    /* We failed showing the Task Dialog, use the old message box! */
   1.128 -    return WIN_ShowOldMessageBox(messageboxdata, buttonid);
   1.129 +/* TaskDialogIndirect procedure
   1.130 + * This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK.
   1.131 + */
   1.132 +typedef HRESULT(FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
   1.133 +
   1.134 +int
   1.135 +WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   1.136 +{
   1.137 +    HWND ParentWindow = NULL;
   1.138 +    wchar_t *wmessage;
   1.139 +    wchar_t *wtitle;
   1.140 +    TASKDIALOGCONFIG TaskConfig;
   1.141 +    TASKDIALOG_BUTTON *pButtons;
   1.142 +    TASKDIALOG_BUTTON *pButton;
   1.143 +    HMODULE hComctl32;
   1.144 +    TASKDIALOGINDIRECTPROC pfnTaskDialogIndirect;
   1.145 +    HRESULT hr;
   1.146 +    int nButton;
   1.147 +    int nCancelButton;
   1.148 +    int i;
   1.149 +
   1.150 +    /* If we cannot load comctl32.dll use the old messagebox! */
   1.151 +    hComctl32 = LoadLibrary(TEXT("Comctl32.dll"));
   1.152 +    if (hComctl32 == NULL) {
   1.153 +        return WIN_ShowOldMessageBox(messageboxdata,buttonid);
   1.154 +    }
   1.155 +    
   1.156 +    /* If TaskDialogIndirect doesn't exist use the old messagebox!
   1.157 +       This will fail prior to Windows Vista.
   1.158 +       The manifest file in the application may require targeting version 6 of comctl32.dll, even
   1.159 +       when we use LoadLibrary here!
   1.160 +       If you don't want to bother with manifests, put this #pragma in your app's source code somewhere:
   1.161 +       pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0'  processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
   1.162 +     */
   1.163 +    pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC) GetProcAddress(hComctl32, "TaskDialogIndirect");
   1.164 +    if (pfnTaskDialogIndirect == NULL) {
   1.165 +        FreeLibrary(hComctl32);
   1.166 +        return WIN_ShowOldMessageBox(messageboxdata, buttonid);
   1.167 +    }
   1.168 +
   1.169 +    /* If we have a parent window, get the Instance and HWND for them
   1.170 +       so that our little dialog gets exclusive focus at all times. */
   1.171 +    if (messageboxdata->window) {
   1.172 +        ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd;
   1.173 +    }
   1.174 +
   1.175 +    wmessage = WIN_UTF8ToString(messageboxdata->message);
   1.176 +    wtitle = WIN_UTF8ToString(messageboxdata->title);
   1.177 +
   1.178 +    SDL_zero(TaskConfig);
   1.179 +    TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG);
   1.180 +    TaskConfig.hwndParent = ParentWindow;
   1.181 +    TaskConfig.dwFlags = TDF_SIZE_TO_CONTENT;
   1.182 +    TaskConfig.pszWindowTitle = wtitle;
   1.183 +    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
   1.184 +        TaskConfig.pszMainIcon = TD_ERROR_ICON;
   1.185 +    } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
   1.186 +        TaskConfig.pszMainIcon = TD_WARNING_ICON;
   1.187 +    } else if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) {
   1.188 +        TaskConfig.pszMainIcon = TD_INFORMATION_ICON;
   1.189 +    } else {
   1.190 +        TaskConfig.pszMainIcon = NULL;
   1.191 +    }
   1.192 +
   1.193 +    TaskConfig.pszContent = wmessage;
   1.194 +    TaskConfig.cButtons = messageboxdata->numbuttons;
   1.195 +    pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
   1.196 +    TaskConfig.nDefaultButton = 0;
   1.197 +    for (i = 0; i < messageboxdata->numbuttons; i++)
   1.198 +    {
   1.199 +        pButton = &pButtons[messageboxdata->numbuttons-1-i];
   1.200 +        if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
   1.201 +            nCancelButton = messageboxdata->buttons[i].buttonid;
   1.202 +            pButton->nButtonID = 2;
   1.203 +        } else {
   1.204 +            pButton->nButtonID = messageboxdata->buttons[i].buttonid + 1;
   1.205 +            if (pButton->nButtonID >= 2) {
   1.206 +                pButton->nButtonID++;
   1.207 +            }
   1.208 +        }
   1.209 +        pButton->pszButtonText = WIN_UTF8ToString(messageboxdata->buttons[i].text);
   1.210 +        if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
   1.211 +            TaskConfig.nDefaultButton = pButton->nButtonID;
   1.212 +        }
   1.213 +    }
   1.214 +    TaskConfig.pButtons = pButtons;
   1.215 +
   1.216 +    /* Show the Task Dialog */
   1.217 +    hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL);
   1.218 +
   1.219 +    /* Free everything */
   1.220 +    FreeLibrary(hComctl32);
   1.221 +    SDL_free(wmessage);
   1.222 +    SDL_free(wtitle);
   1.223 +    for (i = 0; i < messageboxdata->numbuttons; i++) {
   1.224 +        SDL_free((wchar_t *) pButtons[i].pszButtonText);
   1.225 +    }
   1.226 +    SDL_free(pButtons);
   1.227 +
   1.228 +    /* Check the Task Dialog was successful and give the result */
   1.229 +    if (SUCCEEDED(hr)) {
   1.230 +        if (nButton == 2) {
   1.231 +            *buttonid = nCancelButton;
   1.232 +        } else if (nButton > 2) {
   1.233 +            *buttonid = nButton-1-1;
   1.234 +        } else {
   1.235 +            *buttonid = nButton-1;
   1.236 +        }
   1.237 +        return 0;
   1.238 +    }
   1.239 +
   1.240 +    /* We failed showing the Task Dialog, use the old message box! */
   1.241 +    return WIN_ShowOldMessageBox(messageboxdata, buttonid);
   1.242  }
   1.243  
   1.244  #endif /* SDL_VIDEO_DRIVER_WINDOWS */
     2.1 --- a/src/video/windows/SDL_windowstaskdialog.h	Wed Feb 28 01:54:22 2018 -0500
     2.2 +++ b/src/video/windows/SDL_windowstaskdialog.h	Wed Feb 28 02:14:15 2018 -0500
     2.3 @@ -1,156 +1,156 @@
     2.4 -/*
     2.5 -  Simple DirectMedia Layer
     2.6 -  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
     2.7 -
     2.8 -  This software is provided 'as-is', without any express or implied
     2.9 -  warranty.  In no event will the authors be held liable for any damages
    2.10 -  arising from the use of this software.
    2.11 -
    2.12 -  Permission is granted to anyone to use this software for any purpose,
    2.13 -  including commercial applications, and to alter it and redistribute it
    2.14 -  freely, subject to the following restrictions:
    2.15 -
    2.16 -  1. The origin of this software must not be misrepresented; you must not
    2.17 -     claim that you wrote the original software. If you use this software
    2.18 -     in a product, an acknowledgment in the product documentation would be
    2.19 -     appreciated but is not required.
    2.20 -  2. Altered source versions must be plainly marked as such, and must not be
    2.21 -     misrepresented as being the original software.
    2.22 -  3. This notice may not be removed or altered from any source distribution.
    2.23 -*/
    2.24 -#include <pshpack1.h>
    2.25 -
    2.26 -typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ LONG_PTR lpRefData);
    2.27 -
    2.28 -enum _TASKDIALOG_FLAGS
    2.29 -{
    2.30 -    TDF_ENABLE_HYPERLINKS = 0x0001,
    2.31 -    TDF_USE_HICON_MAIN = 0x0002,
    2.32 -    TDF_USE_HICON_FOOTER = 0x0004,
    2.33 -    TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
    2.34 -    TDF_USE_COMMAND_LINKS = 0x0010,
    2.35 -    TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
    2.36 -    TDF_EXPAND_FOOTER_AREA = 0x0040,
    2.37 -    TDF_EXPANDED_BY_DEFAULT = 0x0080,
    2.38 -    TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
    2.39 -    TDF_SHOW_PROGRESS_BAR = 0x0200,
    2.40 -    TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,
    2.41 -    TDF_CALLBACK_TIMER = 0x0800,
    2.42 -    TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
    2.43 -    TDF_RTL_LAYOUT = 0x2000,
    2.44 -    TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,
    2.45 -    TDF_CAN_BE_MINIMIZED = 0x8000,
    2.46 -    //#if (NTDDI_VERSION >= NTDDI_WIN8)
    2.47 -    TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog
    2.48 -                                        //#endif // (NTDDI_VERSION >= NTDDI_WIN8)
    2.49 -                                        TDF_SIZE_TO_CONTENT = 0x01000000  // used by ShellMessageBox to emulate MessageBox sizing behavior
    2.50 -};
    2.51 -typedef int TASKDIALOG_FLAGS;                         // Note: _TASKDIALOG_FLAGS is an int
    2.52 -
    2.53 -typedef enum _TASKDIALOG_MESSAGES
    2.54 -{
    2.55 -    TDM_NAVIGATE_PAGE = WM_USER + 101,
    2.56 -    TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID
    2.57 -    TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
    2.58 -    TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state
    2.59 -    TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
    2.60 -    TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position
    2.61 -    TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
    2.62 -    TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
    2.63 -    TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID
    2.64 -    TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
    2.65 -    TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
    2.66 -    TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
    2.67 -    TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
    2.68 -    TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
    2.69 -    TDM_UPDATE_ICON = WM_USER + 116  // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
    2.70 -} TASKDIALOG_MESSAGES;
    2.71 -
    2.72 -typedef enum _TASKDIALOG_NOTIFICATIONS
    2.73 -{
    2.74 -    TDN_CREATED = 0,
    2.75 -    TDN_NAVIGATED = 1,
    2.76 -    TDN_BUTTON_CLICKED = 2,            // wParam = Button ID
    2.77 -    TDN_HYPERLINK_CLICKED = 3,            // lParam = (LPCWSTR)pszHREF
    2.78 -    TDN_TIMER = 4,            // wParam = Milliseconds since dialog created or timer reset
    2.79 -    TDN_DESTROYED = 5,
    2.80 -    TDN_RADIO_BUTTON_CLICKED = 6,            // wParam = Radio Button ID
    2.81 -    TDN_DIALOG_CONSTRUCTED = 7,
    2.82 -    TDN_VERIFICATION_CLICKED = 8,             // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
    2.83 -    TDN_HELP = 9,
    2.84 -    TDN_EXPANDO_BUTTON_CLICKED = 10            // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
    2.85 -} TASKDIALOG_NOTIFICATIONS;
    2.86 -
    2.87 -typedef struct _TASKDIALOG_BUTTON
    2.88 -{
    2.89 -    int     nButtonID;
    2.90 -    PCWSTR  pszButtonText;
    2.91 -} TASKDIALOG_BUTTON;
    2.92 -
    2.93 -typedef enum _TASKDIALOG_ELEMENTS
    2.94 -{
    2.95 -    TDE_CONTENT,
    2.96 -    TDE_EXPANDED_INFORMATION,
    2.97 -    TDE_FOOTER,
    2.98 -    TDE_MAIN_INSTRUCTION
    2.99 -} TASKDIALOG_ELEMENTS;
   2.100 -
   2.101 -typedef enum _TASKDIALOG_ICON_ELEMENTS
   2.102 -{
   2.103 -    TDIE_ICON_MAIN,
   2.104 -    TDIE_ICON_FOOTER
   2.105 -} TASKDIALOG_ICON_ELEMENTS;
   2.106 -
   2.107 -#define TD_WARNING_ICON         MAKEINTRESOURCEW(-1)
   2.108 -#define TD_ERROR_ICON           MAKEINTRESOURCEW(-2)
   2.109 -#define TD_INFORMATION_ICON     MAKEINTRESOURCEW(-3)
   2.110 -#define TD_SHIELD_ICON          MAKEINTRESOURCEW(-4)
   2.111 -
   2.112 -enum _TASKDIALOG_COMMON_BUTTON_FLAGS
   2.113 -{
   2.114 -    TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK
   2.115 -    TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES
   2.116 -    TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO
   2.117 -    TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL
   2.118 -    TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY
   2.119 -    TDCBF_CLOSE_BUTTON = 0x0020  // selected control return value IDCLOSE
   2.120 -};
   2.121 -typedef int TASKDIALOG_COMMON_BUTTON_FLAGS;           // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
   2.122 -
   2.123 -typedef struct _TASKDIALOGCONFIG
   2.124 -{
   2.125 -    UINT        cbSize;
   2.126 -    HWND        hwndParent;                             // incorrectly named, this is the owner window, not a parent.
   2.127 -    HINSTANCE   hInstance;                              // used for MAKEINTRESOURCE() strings
   2.128 -    TASKDIALOG_FLAGS                dwFlags;            // TASKDIALOG_FLAGS (TDF_XXX) flags
   2.129 -    TASKDIALOG_COMMON_BUTTON_FLAGS  dwCommonButtons;    // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
   2.130 -    PCWSTR      pszWindowTitle;                         // string or MAKEINTRESOURCE()
   2.131 -    union
   2.132 -    {
   2.133 -        HICON   hMainIcon;
   2.134 -        PCWSTR  pszMainIcon;
   2.135 -    } DUMMYUNIONNAME;
   2.136 -    PCWSTR      pszMainInstruction;
   2.137 -    PCWSTR      pszContent;
   2.138 -    UINT        cButtons;
   2.139 -    const TASKDIALOG_BUTTON  *pButtons;
   2.140 -    int         nDefaultButton;
   2.141 -    UINT        cRadioButtons;
   2.142 -    const TASKDIALOG_BUTTON  *pRadioButtons;
   2.143 -    int         nDefaultRadioButton;
   2.144 -    PCWSTR      pszVerificationText;
   2.145 -    PCWSTR      pszExpandedInformation;
   2.146 -    PCWSTR      pszExpandedControlText;
   2.147 -    PCWSTR      pszCollapsedControlText;
   2.148 -    union
   2.149 -    {
   2.150 -        HICON   hFooterIcon;
   2.151 -        PCWSTR  pszFooterIcon;
   2.152 -    } DUMMYUNIONNAME2;
   2.153 -    PCWSTR      pszFooter;
   2.154 -    PFTASKDIALOGCALLBACK pfCallback;
   2.155 -    LONG_PTR    lpCallbackData;
   2.156 -    UINT        cxWidth;                                // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
   2.157 -} TASKDIALOGCONFIG;
   2.158 -
   2.159 -#include <poppack.h>
   2.160 +/*
   2.161 +  Simple DirectMedia Layer
   2.162 +  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
   2.163 +
   2.164 +  This software is provided 'as-is', without any express or implied
   2.165 +  warranty.  In no event will the authors be held liable for any damages
   2.166 +  arising from the use of this software.
   2.167 +
   2.168 +  Permission is granted to anyone to use this software for any purpose,
   2.169 +  including commercial applications, and to alter it and redistribute it
   2.170 +  freely, subject to the following restrictions:
   2.171 +
   2.172 +  1. The origin of this software must not be misrepresented; you must not
   2.173 +     claim that you wrote the original software. If you use this software
   2.174 +     in a product, an acknowledgment in the product documentation would be
   2.175 +     appreciated but is not required.
   2.176 +  2. Altered source versions must be plainly marked as such, and must not be
   2.177 +     misrepresented as being the original software.
   2.178 +  3. This notice may not be removed or altered from any source distribution.
   2.179 +*/
   2.180 +#include <pshpack1.h>
   2.181 +
   2.182 +typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ LONG_PTR lpRefData);
   2.183 +
   2.184 +enum _TASKDIALOG_FLAGS
   2.185 +{
   2.186 +    TDF_ENABLE_HYPERLINKS = 0x0001,
   2.187 +    TDF_USE_HICON_MAIN = 0x0002,
   2.188 +    TDF_USE_HICON_FOOTER = 0x0004,
   2.189 +    TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
   2.190 +    TDF_USE_COMMAND_LINKS = 0x0010,
   2.191 +    TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
   2.192 +    TDF_EXPAND_FOOTER_AREA = 0x0040,
   2.193 +    TDF_EXPANDED_BY_DEFAULT = 0x0080,
   2.194 +    TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
   2.195 +    TDF_SHOW_PROGRESS_BAR = 0x0200,
   2.196 +    TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,
   2.197 +    TDF_CALLBACK_TIMER = 0x0800,
   2.198 +    TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
   2.199 +    TDF_RTL_LAYOUT = 0x2000,
   2.200 +    TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,
   2.201 +    TDF_CAN_BE_MINIMIZED = 0x8000,
   2.202 +    //#if (NTDDI_VERSION >= NTDDI_WIN8)
   2.203 +    TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog
   2.204 +                                        //#endif // (NTDDI_VERSION >= NTDDI_WIN8)
   2.205 +                                        TDF_SIZE_TO_CONTENT = 0x01000000  // used by ShellMessageBox to emulate MessageBox sizing behavior
   2.206 +};
   2.207 +typedef int TASKDIALOG_FLAGS;                         // Note: _TASKDIALOG_FLAGS is an int
   2.208 +
   2.209 +typedef enum _TASKDIALOG_MESSAGES
   2.210 +{
   2.211 +    TDM_NAVIGATE_PAGE = WM_USER + 101,
   2.212 +    TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID
   2.213 +    TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
   2.214 +    TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state
   2.215 +    TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
   2.216 +    TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position
   2.217 +    TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
   2.218 +    TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
   2.219 +    TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID
   2.220 +    TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
   2.221 +    TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
   2.222 +    TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
   2.223 +    TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
   2.224 +    TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
   2.225 +    TDM_UPDATE_ICON = WM_USER + 116  // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
   2.226 +} TASKDIALOG_MESSAGES;
   2.227 +
   2.228 +typedef enum _TASKDIALOG_NOTIFICATIONS
   2.229 +{
   2.230 +    TDN_CREATED = 0,
   2.231 +    TDN_NAVIGATED = 1,
   2.232 +    TDN_BUTTON_CLICKED = 2,            // wParam = Button ID
   2.233 +    TDN_HYPERLINK_CLICKED = 3,            // lParam = (LPCWSTR)pszHREF
   2.234 +    TDN_TIMER = 4,            // wParam = Milliseconds since dialog created or timer reset
   2.235 +    TDN_DESTROYED = 5,
   2.236 +    TDN_RADIO_BUTTON_CLICKED = 6,            // wParam = Radio Button ID
   2.237 +    TDN_DIALOG_CONSTRUCTED = 7,
   2.238 +    TDN_VERIFICATION_CLICKED = 8,             // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
   2.239 +    TDN_HELP = 9,
   2.240 +    TDN_EXPANDO_BUTTON_CLICKED = 10            // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
   2.241 +} TASKDIALOG_NOTIFICATIONS;
   2.242 +
   2.243 +typedef struct _TASKDIALOG_BUTTON
   2.244 +{
   2.245 +    int     nButtonID;
   2.246 +    PCWSTR  pszButtonText;
   2.247 +} TASKDIALOG_BUTTON;
   2.248 +
   2.249 +typedef enum _TASKDIALOG_ELEMENTS
   2.250 +{
   2.251 +    TDE_CONTENT,
   2.252 +    TDE_EXPANDED_INFORMATION,
   2.253 +    TDE_FOOTER,
   2.254 +    TDE_MAIN_INSTRUCTION
   2.255 +} TASKDIALOG_ELEMENTS;
   2.256 +
   2.257 +typedef enum _TASKDIALOG_ICON_ELEMENTS
   2.258 +{
   2.259 +    TDIE_ICON_MAIN,
   2.260 +    TDIE_ICON_FOOTER
   2.261 +} TASKDIALOG_ICON_ELEMENTS;
   2.262 +
   2.263 +#define TD_WARNING_ICON         MAKEINTRESOURCEW(-1)
   2.264 +#define TD_ERROR_ICON           MAKEINTRESOURCEW(-2)
   2.265 +#define TD_INFORMATION_ICON     MAKEINTRESOURCEW(-3)
   2.266 +#define TD_SHIELD_ICON          MAKEINTRESOURCEW(-4)
   2.267 +
   2.268 +enum _TASKDIALOG_COMMON_BUTTON_FLAGS
   2.269 +{
   2.270 +    TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK
   2.271 +    TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES
   2.272 +    TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO
   2.273 +    TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL
   2.274 +    TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY
   2.275 +    TDCBF_CLOSE_BUTTON = 0x0020  // selected control return value IDCLOSE
   2.276 +};
   2.277 +typedef int TASKDIALOG_COMMON_BUTTON_FLAGS;           // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
   2.278 +
   2.279 +typedef struct _TASKDIALOGCONFIG
   2.280 +{
   2.281 +    UINT        cbSize;
   2.282 +    HWND        hwndParent;                             // incorrectly named, this is the owner window, not a parent.
   2.283 +    HINSTANCE   hInstance;                              // used for MAKEINTRESOURCE() strings
   2.284 +    TASKDIALOG_FLAGS                dwFlags;            // TASKDIALOG_FLAGS (TDF_XXX) flags
   2.285 +    TASKDIALOG_COMMON_BUTTON_FLAGS  dwCommonButtons;    // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
   2.286 +    PCWSTR      pszWindowTitle;                         // string or MAKEINTRESOURCE()
   2.287 +    union
   2.288 +    {
   2.289 +        HICON   hMainIcon;
   2.290 +        PCWSTR  pszMainIcon;
   2.291 +    } DUMMYUNIONNAME;
   2.292 +    PCWSTR      pszMainInstruction;
   2.293 +    PCWSTR      pszContent;
   2.294 +    UINT        cButtons;
   2.295 +    const TASKDIALOG_BUTTON  *pButtons;
   2.296 +    int         nDefaultButton;
   2.297 +    UINT        cRadioButtons;
   2.298 +    const TASKDIALOG_BUTTON  *pRadioButtons;
   2.299 +    int         nDefaultRadioButton;
   2.300 +    PCWSTR      pszVerificationText;
   2.301 +    PCWSTR      pszExpandedInformation;
   2.302 +    PCWSTR      pszExpandedControlText;
   2.303 +    PCWSTR      pszCollapsedControlText;
   2.304 +    union
   2.305 +    {
   2.306 +        HICON   hFooterIcon;
   2.307 +        PCWSTR  pszFooterIcon;
   2.308 +    } DUMMYUNIONNAME2;
   2.309 +    PCWSTR      pszFooter;
   2.310 +    PFTASKDIALOGCALLBACK pfCallback;
   2.311 +    LONG_PTR    lpCallbackData;
   2.312 +    UINT        cxWidth;                                // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
   2.313 +} TASKDIALOGCONFIG;
   2.314 +
   2.315 +#include <poppack.h>