Convert existing MessageBox calls to TaskDialog

This commit is contained in:
RichardG867
2020-01-13 17:11:54 -03:00
parent f21cbbb117
commit af6cead246
2 changed files with 61 additions and 35 deletions

View File

@@ -43,34 +43,36 @@ int
ui_msgbox(int flags, void *arg) ui_msgbox(int flags, void *arg)
{ {
WCHAR temp[512]; WCHAR temp[512];
DWORD fl = 0; WCHAR *icon = NULL;
TASKDIALOG_COMMON_BUTTON_FLAGS buttons = TDCBF_OK_BUTTON;
WCHAR *str = NULL; WCHAR *str = NULL;
WCHAR *cap = NULL; WCHAR *instr = NULL;
int res = 0;
switch(flags & 0x1f) { switch(flags & 0x1f) {
case MBX_INFO: /* just an informational message */ case MBX_INFO: /* just an informational message */
fl = (MB_OK | MB_ICONINFORMATION); icon = TD_INFORMATION_ICON;
cap = plat_get_string(IDS_STRINGS); /* "86Box" */ instr = plat_get_string(IDS_STRINGS); /* "86Box" */
break; break;
case MBX_ERROR: /* error message */ case MBX_ERROR: /* error message */
if (flags & MBX_FATAL) { if (flags & MBX_FATAL) {
fl = (MB_OK | MB_ICONERROR); icon = TD_ERROR_ICON;
cap = plat_get_string(IDS_2050); /* "Fatal Error"*/ instr = plat_get_string(IDS_2050); /* "Fatal Error"*/
} else { } else {
fl = (MB_OK | MB_ICONWARNING); icon = TD_WARNING_ICON;
cap = plat_get_string(IDS_2049); /* "Error" */ instr = plat_get_string(IDS_2049); /* "Error" */
} }
break; break;
case MBX_QUESTION: /* question */ case MBX_QUESTION: /* question */
fl = (MB_YESNOCANCEL | MB_ICONQUESTION); buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON;
cap = plat_get_string(IDS_STRINGS); /* "86Box" */ instr = plat_get_string(IDS_STRINGS); /* "86Box" */
break; break;
case MBX_QUESTION_YN: /* question */ case MBX_QUESTION_YN: /* question */
fl = (MB_YESNO | MB_ICONQUESTION); buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON;
cap = plat_get_string(IDS_STRINGS); /* "86Box" */ instr = plat_get_string(IDS_STRINGS); /* "86Box" */
break; break;
} }
@@ -99,17 +101,21 @@ ui_msgbox(int flags, void *arg)
} }
/* At any rate, we do have a valid (wide) string now. */ /* At any rate, we do have a valid (wide) string now. */
fl = MessageBox(hwndMain, /* our main window */ TaskDialog(hwndMain, /* our main window */
str, /* error message etc */ NULL, /* no icon resource */
cap, /* window caption */ plat_get_string(IDS_STRINGS), /* window caption */
fl); instr, /* main instruction */
str, /* error message */
buttons,
icon,
&res); /* pointer to result */
/* Convert return values to generic ones. */ /* Convert return values to generic ones. */
if (fl == IDNO) fl = 1; if (res == IDNO) res = 1;
else if (fl == IDCANCEL) fl = -1; else if (res == IDCANCEL) res = -1;
else fl = 0; else res = 0;
return(fl); return(res);
} }

View File

@@ -836,10 +836,14 @@ ui_init(int nCmdShow)
if (settings_only) { if (settings_only) {
if (! pc_init_modules()) { if (! pc_init_modules()) {
/* Dang, no ROMs found at all! */ /* Dang, no ROMs found at all! */
MessageBox(hwnd, TaskDialog(hwnd,
plat_get_string(IDS_2056), NULL,
plat_get_string(IDS_STRINGS),
plat_get_string(IDS_2050), plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR); plat_get_string(IDS_2056),
TDCBF_OK_BUTTON,
TD_ERROR_ICON,
NULL);
return(6); return(6);
} }
@@ -926,10 +930,14 @@ ui_init(int nCmdShow)
ridev.dwFlags = RIDEV_NOHOTKEYS; ridev.dwFlags = RIDEV_NOHOTKEYS;
ridev.hwndTarget = NULL; /* current focus window */ ridev.hwndTarget = NULL; /* current focus window */
if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) { if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) {
MessageBox(hwndMain, TaskDialog(hwnd,
plat_get_string(IDS_2114), NULL,
plat_get_string(IDS_STRINGS),
plat_get_string(IDS_2050), plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR); plat_get_string(IDS_2114),
TDCBF_OK_BUTTON,
TD_ERROR_ICON,
NULL);
return(4); return(4);
} }
keyboard_getkeymap(); keyboard_getkeymap();
@@ -940,10 +948,14 @@ ui_init(int nCmdShow)
/* Load the accelerator table */ /* Load the accelerator table */
haccel = LoadAccelerators(hinstance, ACCEL_NAME); haccel = LoadAccelerators(hinstance, ACCEL_NAME);
if (haccel == NULL) { if (haccel == NULL) {
MessageBox(hwndMain, TaskDialog(hwnd,
plat_get_string(IDS_2113), NULL,
plat_get_string(IDS_STRINGS),
plat_get_string(IDS_2050), plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR); plat_get_string(IDS_2113),
TDCBF_OK_BUTTON,
TD_ERROR_ICON,
NULL);
return(3); return(3);
} }
@@ -973,19 +985,27 @@ ui_init(int nCmdShow)
/* All done, fire up the actual emulated machine. */ /* All done, fire up the actual emulated machine. */
if (! pc_init_modules()) { if (! pc_init_modules()) {
/* Dang, no ROMs found at all! */ /* Dang, no ROMs found at all! */
MessageBox(hwnd, TaskDialog(hwnd,
plat_get_string(IDS_2056), NULL,
plat_get_string(IDS_STRINGS),
plat_get_string(IDS_2050), plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR); plat_get_string(IDS_2056),
TDCBF_OK_BUTTON,
TD_ERROR_ICON,
NULL);
return(6); return(6);
} }
/* Initialize the configured Video API. */ /* Initialize the configured Video API. */
if (! plat_setvid(vid_api)) { if (! plat_setvid(vid_api)) {
MessageBox(hwnd, TaskDialog(hwnd,
plat_get_string(IDS_2095), NULL,
plat_get_string(IDS_STRINGS),
plat_get_string(IDS_2050), plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR); plat_get_string(IDS_2095),
TDCBF_OK_BUTTON,
TD_ERROR_ICON,
NULL);
return(5); return(5);
} }