| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #include <corecrt_internal.h>
|
| #include <corecrt_internal_traits.h>
|
|
|
|
|
|
|
| namespace
|
| {
|
| template <typename Character>
|
| struct message_box_arguments
|
| {
|
| Character const* _caption;
|
| Character const* _text;
|
| unsigned int _type;
|
| int _result;
|
| };
|
| }
|
|
|
| template <typename Character>
|
| static int __cdecl common_show_message_box(
|
| Character const* const text,
|
| Character const* const caption,
|
| unsigned const type
|
| ) throw()
|
| {
|
| using traits = __crt_char_traits<Character>;
|
|
|
| bool const debugger_attached = IsDebuggerPresent();
|
| if (debugger_attached)
|
| {
|
|
|
|
|
| if (text)
|
| {
|
| traits::output_debug_string(text);
|
| }
|
|
|
|
|
|
|
|
|
|
|
| bool const is_desktop_app = __acrt_get_windowing_model_policy() == windowing_model_policy_hwnd;
|
| if (!is_desktop_app)
|
| {
|
| return IDRETRY;
|
| }
|
| }
|
|
|
| bool const show_ui = __acrt_get_developer_information_policy() == developer_information_policy_ui;
|
| if (!show_ui || !__acrt_can_show_message_box())
|
| {
|
|
|
|
|
|
|
| return debugger_attached ? IDRETRY : IDABORT;
|
| }
|
|
|
|
|
|
|
|
|
| if (!__acrt_is_interactive())
|
| {
|
| return traits::message_box(nullptr, text, caption, type | MB_SERVICE_NOTIFICATION);
|
| }
|
|
|
| return traits::message_box(__acrt_get_parent_window(), text, caption, type);
|
| }
|
|
|
| extern "C" int __cdecl __acrt_show_narrow_message_box(
|
| char const* const text,
|
| char const* const caption,
|
| unsigned const type
|
| )
|
| {
|
| return common_show_message_box(text, caption, type);
|
| }
|
|
|
| extern "C" int __cdecl __acrt_show_wide_message_box(
|
| wchar_t const* const text,
|
| wchar_t const* const caption,
|
| unsigned const type
|
| )
|
| {
|
| return common_show_message_box(text, caption, type);
|
| }
|
|
|