From af6cead246a1301d57308dcf264af36d40a313b4 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Mon, 13 Jan 2020 17:11:54 -0300 Subject: [PATCH] Convert existing MessageBox calls to TaskDialog --- src/win/win_dialog.c | 46 ++++++++++++++++++++++------------------ src/win/win_ui.c | 50 +++++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/win/win_dialog.c b/src/win/win_dialog.c index 729be881e..a17d96953 100644 --- a/src/win/win_dialog.c +++ b/src/win/win_dialog.c @@ -43,34 +43,36 @@ int ui_msgbox(int flags, void *arg) { WCHAR temp[512]; - DWORD fl = 0; + WCHAR *icon = NULL; + TASKDIALOG_COMMON_BUTTON_FLAGS buttons = TDCBF_OK_BUTTON; WCHAR *str = NULL; - WCHAR *cap = NULL; + WCHAR *instr = NULL; + int res = 0; switch(flags & 0x1f) { case MBX_INFO: /* just an informational message */ - fl = (MB_OK | MB_ICONINFORMATION); - cap = plat_get_string(IDS_STRINGS); /* "86Box" */ + icon = TD_INFORMATION_ICON; + instr = plat_get_string(IDS_STRINGS); /* "86Box" */ break; case MBX_ERROR: /* error message */ if (flags & MBX_FATAL) { - fl = (MB_OK | MB_ICONERROR); - cap = plat_get_string(IDS_2050); /* "Fatal Error"*/ + icon = TD_ERROR_ICON; + instr = plat_get_string(IDS_2050); /* "Fatal Error"*/ } else { - fl = (MB_OK | MB_ICONWARNING); - cap = plat_get_string(IDS_2049); /* "Error" */ + icon = TD_WARNING_ICON; + instr = plat_get_string(IDS_2049); /* "Error" */ } break; case MBX_QUESTION: /* question */ - fl = (MB_YESNOCANCEL | MB_ICONQUESTION); - cap = plat_get_string(IDS_STRINGS); /* "86Box" */ + buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON; + instr = plat_get_string(IDS_STRINGS); /* "86Box" */ break; case MBX_QUESTION_YN: /* question */ - fl = (MB_YESNO | MB_ICONQUESTION); - cap = plat_get_string(IDS_STRINGS); /* "86Box" */ + buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; + instr = plat_get_string(IDS_STRINGS); /* "86Box" */ break; } @@ -99,17 +101,21 @@ ui_msgbox(int flags, void *arg) } /* At any rate, we do have a valid (wide) string now. */ - fl = MessageBox(hwndMain, /* our main window */ - str, /* error message etc */ - cap, /* window caption */ - fl); + TaskDialog(hwndMain, /* our main window */ + NULL, /* no icon resource */ + plat_get_string(IDS_STRINGS), /* window caption */ + instr, /* main instruction */ + str, /* error message */ + buttons, + icon, + &res); /* pointer to result */ /* Convert return values to generic ones. */ - if (fl == IDNO) fl = 1; - else if (fl == IDCANCEL) fl = -1; - else fl = 0; + if (res == IDNO) res = 1; + else if (res == IDCANCEL) res = -1; + else res = 0; - return(fl); + return(res); } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 4e99eebb4..71f89a83b 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -836,10 +836,14 @@ ui_init(int nCmdShow) if (settings_only) { if (! pc_init_modules()) { /* Dang, no ROMs found at all! */ - MessageBox(hwnd, - plat_get_string(IDS_2056), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2056), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(6); } @@ -926,10 +930,14 @@ ui_init(int nCmdShow) ridev.dwFlags = RIDEV_NOHOTKEYS; ridev.hwndTarget = NULL; /* current focus window */ if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) { - MessageBox(hwndMain, - plat_get_string(IDS_2114), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2114), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(4); } keyboard_getkeymap(); @@ -940,10 +948,14 @@ ui_init(int nCmdShow) /* Load the accelerator table */ haccel = LoadAccelerators(hinstance, ACCEL_NAME); if (haccel == NULL) { - MessageBox(hwndMain, - plat_get_string(IDS_2113), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2113), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(3); } @@ -973,19 +985,27 @@ ui_init(int nCmdShow) /* All done, fire up the actual emulated machine. */ if (! pc_init_modules()) { /* Dang, no ROMs found at all! */ - MessageBox(hwnd, - plat_get_string(IDS_2056), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2056), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(6); } /* Initialize the configured Video API. */ if (! plat_setvid(vid_api)) { - MessageBox(hwnd, - plat_get_string(IDS_2095), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2095), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(5); }