Bug 1526820 - Handle WM_INITDIALOG in the ColorPicker hook to enable keyboard focus r=cmartin

WM_INITDIALOG is a special case for this hook. Returning TRUE tells it to set they keyboard focus.
In all other cases returning 0 from the hook invokes the standard behavior.

Differential Revision: https://phabricator.services.mozilla.com/D87870
This commit is contained in:
Tom Schuster 2020-08-24 16:58:11 +00:00
Родитель 0e1968be4a
Коммит 14657c9047
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -154,6 +154,17 @@ void AsyncColorChooser::Update(COLORREF aColor) {
return 0;
}
if (aMsg == WM_INITDIALOG) {
// "The default dialog box procedure processes the WM_INITDIALOG message
// before passing it to the hook procedure.
// For all other messages, the hook procedure receives the message first."
// https://docs.microsoft.com/en-us/windows/win32/api/commdlg/nc-commdlg-lpcchookproc
// "The dialog box procedure should return TRUE to direct the system to
// set the keyboard focus to the control specified by wParam."
// https://docs.microsoft.com/en-us/windows/win32/dlgbox/wm-initdialog
return 1;
}
if (aMsg == WM_CTLCOLORSTATIC) {
// The color picker does not expose a proper way to retrieve the current
// color, so we need to obtain it from the static control displaying the
@ -164,6 +175,7 @@ void AsyncColorChooser::Update(COLORREF aColor) {
}
}
// Let the default dialog box procedure processes the message.
return 0;
}