From 5a74998a94601ce3b1e5d1f6bd903f6aeb75a1f1 Mon Sep 17 00:00:00 2001 From: oov Date: Wed, 28 Feb 2024 05:12:19 +0900 Subject: [PATCH] use warning icon in some cases on error message --- src/c/error_gcmz.c | 5 ++++- src/c/error_gcmz.h | 1 + src/c/gcmzdrops.c | 27 +++++++++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/c/error_gcmz.c b/src/c/error_gcmz.c index 2545a0f..25ba06b 100644 --- a/src/c/error_gcmz.c +++ b/src/c/error_gcmz.c @@ -180,6 +180,7 @@ gcmz_error_format(error e, struct wstr *const dest, wchar_t const *const referen struct error_message_box_task_data { HWND window; + UINT flags; struct wstr msg; struct wstr title; @@ -187,7 +188,7 @@ struct error_message_box_task_data { static void error_message_box_task(void *userdata) { struct error_message_box_task_data *d = userdata; - message_box(d->window, d->msg.ptr, d->title.ptr, MB_ICONERROR); + message_box(d->window, d->msg.ptr, d->title.ptr, d->flags); ereport(sfree(&d->title)); ereport(sfree(&d->msg)); ereport(mem_free(&d)); @@ -195,6 +196,7 @@ static void error_message_box_task(void *userdata) { void gcmz_error_message_box(error e, HWND const window, + UINT const flags, bool const deferred, char const *const title, wchar_t const *const reference, @@ -223,6 +225,7 @@ void gcmz_error_message_box(error e, goto cleanup; } d->window = window; + d->flags = flags; d->msg = msg; msg = (struct wstr){0}; d->title = wide_title; diff --git a/src/c/error_gcmz.h b/src/c/error_gcmz.h index f07f4b5..8b3f9f7 100644 --- a/src/c/error_gcmz.h +++ b/src/c/error_gcmz.h @@ -38,6 +38,7 @@ NODISCARD error gcmz_error_format(error e, struct wstr *const dest, wchar_t const *const reference, char const *const format, ...); void gcmz_error_message_box(error e, HWND const window, + UINT const flags, bool const deferred, char const *const title, wchar_t const *const reference, diff --git a/src/c/gcmzdrops.c b/src/c/gcmzdrops.c index 091c889..2254f57 100644 --- a/src/c/gcmzdrops.c +++ b/src/c/gcmzdrops.c @@ -60,7 +60,7 @@ static void generic_lua_error_handler(error e, char const *const default_msg) { msg = default_msg; cleanup: if (msg) { - gcmz_error_message_box(e, aviutl_get_exedit_window_must(), true, gettext("Error"), NULL, "%1$s", msg); + gcmz_error_message_box(e, aviutl_get_exedit_window_must(), MB_ICONERROR, true, gettext("Error"), NULL, "%1$s", msg); } files_cleanup(true); } @@ -674,6 +674,7 @@ static void request_callback(struct api_request_params *const params, api_reques if (efailed(err)) { gcmz_error_message_box(err, (HWND)params->userdata, + MB_ICONERROR, false, gettext("Error"), NULL, @@ -717,7 +718,7 @@ static BOOL wndproc_init(HWND const window) { efree(&err); } gui_lock(); - gcmz_error_message_box(err, window, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg); + gcmz_error_message_box(err, window, MB_ICONERROR, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg); return FALSE; } @@ -734,8 +735,15 @@ static BOOL wndproc_init(HWND const window) { err = drop_target_new(&dt); if (efailed(err)) { gui_lock(); - gcmz_error_message_box( - err, window, false, title, L"%1$s%2$s", "%1$s\n\n%2$s", msg_head, gettext("Failed to create IDropTarget.")); + gcmz_error_message_box(err, + window, + MB_ICONERROR, + false, + title, + L"%1$s%2$s", + "%1$s\n\n%2$s", + msg_head, + gettext("Failed to create IDropTarget.")); return FALSE; } dt->super.lpVtbl->AddRef((void *)dt); @@ -759,7 +767,7 @@ static BOOL wndproc_init(HWND const window) { efree(&err); } gui_lock(); - gcmz_error_message_box(err, window, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg); + gcmz_error_message_box(err, window, MB_ICONERROR, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg); return FALSE; } g_drop_target_registered = SUCCEEDED(hr); @@ -768,6 +776,7 @@ static BOOL wndproc_init(HWND const window) { if (efailed(err)) { gcmz_error_message_box(err, window, + MB_ICONWARNING, false, title, NULL, @@ -782,13 +791,15 @@ static BOOL wndproc_init(HWND const window) { if (efailed(err)) { char const *apimsg = NULL; if (eis_hr(err, HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))) { - apimsg = gettext("This error mainly occurs when multiple instances of AviUtl are running.\n" - "If you need external integration API, please close all instances of AviUtl and start only one instance.\n" - "If you do not need external integration API, you can ignore this message."); + apimsg = gettext( + "This error mainly occurs when multiple instances of AviUtl are running.\n" + "If you need external integration API, please close all instances of AviUtl and start only one instance.\n" + "If you do not need external integration API, you can ignore this message."); efree(&err); } gcmz_error_message_box(err, window, + MB_ICONWARNING, false, title, NULL,