From aa7941d41b2c66066dbc281bfa57364c1a60d863 Mon Sep 17 00:00:00 2001 From: Fabian Maurer Date: Sat, 11 Nov 2017 16:15:17 +0100 Subject: [PATCH] comdlg32/fontdlg: Allow setting value by typing it into the edit fields. The font-dialog allows the user to select a value from the combobox by typing it into its edit field. This operation seems unique to the fontdialog. It works case-insensitively and doesn't change the selection in the edit field. Signed-off-by: Fabian Maurer Signed-off-by: Alexandre Julliard --- dlls/comdlg32/fontdlg.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/dlls/comdlg32/fontdlg.c b/dlls/comdlg32/fontdlg.c index c08b246e129..82992cb5a45 100644 --- a/dlls/comdlg32/fontdlg.c +++ b/dlls/comdlg32/fontdlg.c @@ -940,14 +940,37 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO int i; long l; HDC hdc; + BOOL cmb_selected_by_edit = FALSE; if (!lpcf) return FALSE; + if(HIWORD(wParam) == CBN_EDITCHANGE) + { + int idx; + WCHAR str_edit[256], str_cmb[256]; + int cmb = LOWORD(wParam); + + GetDlgItemTextW(hDlg, cmb, str_edit, sizeof(str_edit) / sizeof(str_edit[0])); + idx = SendDlgItemMessageW(hDlg, cmb, CB_FINDSTRING, -1, (LPARAM)str_edit); + if(idx != -1) + { + SendDlgItemMessageW(hDlg, cmb, CB_GETLBTEXT, idx, (LPARAM)str_cmb); + + /* Select listbox entry only if we have an exact match */ + if(lstrcmpiW(str_edit, str_cmb) == 0) + { + SendDlgItemMessageW(hDlg, cmb, CB_SETCURSEL, idx, 0); + SendDlgItemMessageW(hDlg, cmb, CB_SETEDITSEL, 0, -1); /* Remove edit field selection */ + cmb_selected_by_edit = TRUE; + } + } + } + TRACE("WM_COMMAND wParam=%08X lParam=%08lX\n", (LONG)wParam, lParam); switch (LOWORD(wParam)) { case cmb1: - if (HIWORD(wParam)==CBN_SELCHANGE) + if (HIWORD(wParam) == CBN_SELCHANGE || cmb_selected_by_edit) { INT pointsize; /* save current pointsize */ LONG pstyle; /* save current style */ @@ -998,7 +1021,7 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO case cmb2: case cmb3: case cmb5: - if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED ) + if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == BN_CLICKED || cmb_selected_by_edit) { WCHAR str[256]; WINDOWINFO wininfo;