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

* 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:29 +02:00 committed by GitHub
commit af55e45ce8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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.