fix: dialog.showMessageBox defaultid on Windows (#48520)

* fix: dialog.showMessageBox defaultid on Windows

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update shell/browser/ui/message_box_win.cc

Co-authored-by: Robo <hop2deep@gmail.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2025-10-11 10:02:20 +02:00
committed by GitHub
parent f3f25fd020
commit 7449f3f376

View File

@@ -163,8 +163,19 @@ DialogResult ShowTaskDialogWstr(gfx::AcceleratedWidget parent,
config.dwFlags |= TDF_POSITION_RELATIVE_TO_WINDOW;
}
if (default_id > 0)
config.nDefaultButton = kIDStart + default_id;
if (default_id >= 0 &&
base::checked_cast<size_t>(default_id) < buttons.size()) {
if (!no_link) {
auto common = GetCommonID(buttons[default_id]);
if (common.button != -1) {
config.nDefaultButton = common.id;
} else {
config.nDefaultButton = kIDStart + default_id;
}
} else {
config.nDefaultButton = kIDStart + default_id;
}
}
// TaskDialogIndirect doesn't allow empty name, if we set empty title it
// will show "electron.exe" in title.