Final cleanup
This commit is contained in:
parent
aab78db8b8
commit
001b4a3179
2 changed files with 20 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/strings/string_util.h"
|
||||
|
@ -76,8 +76,7 @@ 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.
|
||||
|
||||
|
@ -86,6 +85,8 @@ int ShowMessageBoxUTF16(HWND parent,
|
|||
config.hwndParent = parent;
|
||||
config.hInstance = GetModuleHandle(NULL);
|
||||
config.dwFlags = flags;
|
||||
|
||||
if (!title.empty())
|
||||
config.pszWindowTitle = title.c_str();
|
||||
|
||||
base::win::ScopedHICON hicon;
|
||||
|
@ -121,8 +122,11 @@ int ShowMessageBoxUTF16(HWND parent,
|
|||
std::map<int, int> id_map;
|
||||
std::vector<TASKDIALOG_BUTTON> dialog_buttons;
|
||||
MapToCommonID(buttons, &id_map, &config.dwCommonButtons, &dialog_buttons);
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue