From 001b4a3179ec9bcea227b394ecc1c9a5647208b6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 8 Jul 2015 16:23:43 +0800 Subject: [PATCH] Final cleanup --- atom/browser/api/lib/dialog.coffee | 3 ++- atom/browser/ui/message_box_win.cc | 30 ++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/atom/browser/api/lib/dialog.coffee b/atom/browser/api/lib/dialog.coffee index 61547aff..7a60b7f8 100644 --- a/atom/browser/api/lib/dialog.coffee +++ b/atom/browser/api/lib/dialog.coffee @@ -113,4 +113,5 @@ module.exports = binding.showErrorBox args... # Mark standard asynchronous functions. -v8Util.setHiddenValue f, 'asynchronous', true for k, f of module.exports +for api in ['showMessageBox', 'showOpenDialog', 'showSaveDialog'] + v8Util.setHiddenValue module.exports[api], 'asynchronous', true diff --git a/atom/browser/ui/message_box_win.cc b/atom/browser/ui/message_box_win.cc index cdedf361..9487013d 100644 --- a/atom/browser/ui/message_box_win.cc +++ b/atom/browser/ui/message_box_win.cc @@ -4,12 +4,12 @@ #include "atom/browser/ui/message_box.h" -#include -#include - #include #include +#include +#include + #include "atom/browser/native_window_views.h" #include "base/callback.h" #include "base/strings/string_util.h" @@ -76,17 +76,18 @@ int ShowMessageBoxUTF16(HWND parent, const base::string16& message, const base::string16& detail, const gfx::ImageSkia& icon) { - TASKDIALOG_FLAGS flags = TDF_SIZE_TO_CONTENT | // show all content. - TDF_USE_COMMAND_LINKS; // custom buttons as links. + TASKDIALOG_FLAGS flags = TDF_SIZE_TO_CONTENT; // show all content. if (cancel_id != 0) flags |= TDF_ALLOW_DIALOG_CANCELLATION; // allow dialog to be cancelled. TASKDIALOGCONFIG config = { 0 }; - config.cbSize = sizeof(config); - config.hwndParent = parent; - config.hInstance = GetModuleHandle(NULL); - config.dwFlags = flags; - config.pszWindowTitle = title.c_str(); + config.cbSize = sizeof(config); + config.hwndParent = parent; + config.hInstance = GetModuleHandle(NULL); + config.dwFlags = flags; + + if (!title.empty()) + config.pszWindowTitle = title.c_str(); base::win::ScopedHICON hicon; if (!icon.isNull()) { @@ -121,8 +122,11 @@ int ShowMessageBoxUTF16(HWND parent, std::map id_map; std::vector dialog_buttons; MapToCommonID(buttons, &id_map, &config.dwCommonButtons, &dialog_buttons); - config.pButtons = &dialog_buttons.front(); - config.cButtons = dialog_buttons.size(); + if (dialog_buttons.size() > 0) { + config.pButtons = &dialog_buttons.front(); + config.cButtons = dialog_buttons.size(); + config.dwFlags |= TDF_USE_COMMAND_LINKS; // custom buttons as links. + } int id = 0; TaskDialogIndirect(&config, &id, NULL, NULL); @@ -207,6 +211,8 @@ void ShowMessageBox(NativeWindow* parent, } void ShowErrorBox(const base::string16& title, const base::string16& content) { + ShowMessageBoxUTF16(NULL, MESSAGE_BOX_TYPE_ERROR, {}, 0, L"Error", title, + content, gfx::ImageSkia()); } } // namespace atom -- 2.43.0