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)
{
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);
}