From: Vladislav Timonin timoninvlad@yandex.ru
--- dlls/comdlg32/navbar.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
diff --git a/dlls/comdlg32/navbar.c b/dlls/comdlg32/navbar.c index 2a2aec022a7..7f763327636 100644 --- a/dlls/comdlg32/navbar.c +++ b/dlls/comdlg32/navbar.c @@ -545,6 +545,65 @@ static LRESULT NAVBAR_PATHEDIT_NCHitTest(HWND hwnd, UINT msg, WPARAM wparam, LPA return DefSubclassProc(hwnd, msg, wparam, lparam); }
+static LRESULT NAVBAR_PATHEDIT_KeyDown(HWND hwnd, NAVBAR_INFO *info, UINT msg, WPARAM wparam, LPARAM lparam) +{ + WORD key = LOWORD(wparam); + + switch (key) { + case VK_BACK: + { + BOOL control = GetKeyState(VK_CONTROL) & 0x8000; + + /* delete word */ + if (control) + { + WCHAR *text = NULL, *ptr = NULL, *end = NULL; + INT text_len = 0; + UINT caret_pos = 0, selection_end = 0; + EDITWORDBREAKPROCW word_break_proc; + + SendMessageW(info->pathedit_hwnd, EM_GETSEL, (WPARAM)&caret_pos, (WPARAM)&selection_end); + if (caret_pos != selection_end) + break; + + text_len = GetWindowTextLengthW(info->pathedit_hwnd); + if (!text_len) + break; + + text = HeapAlloc(GetProcessHeap(), 0, (text_len + 1) * sizeof(WCHAR)); + if (!text) + break; + + if (!GetWindowTextW(info->pathedit_hwnd, text, text_len + 1)) + goto cleanup; + + ptr = text + caret_pos; + end = StrDupW(ptr); + if (!end) + goto cleanup; + + word_break_proc = (EDITWORDBREAKPROCW)SendMessageW(info->pathedit_hwnd, EM_GETWORDBREAKPROC, 0, 0); + caret_pos = word_break_proc(text, caret_pos, text_len, WB_LEFT); + ptr = text + caret_pos; + *ptr = '\0'; + + lstrcatW(ptr, end); + SetWindowTextW(info->pathedit_hwnd, text); + SendMessageW(info->pathedit_hwnd, EM_SETSEL, caret_pos, caret_pos); + + cleanup: + HeapFree(GetProcessHeap(), 0, text); + if (end) + LocalFree(end); + } + + break; + } + } + + return DefSubclassProc(hwnd, msg, wparam, lparam); +} + static LRESULT CALLBACK NAVBAR_PATHEDIT_SubclassProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT_PTR id_subclass, DWORD_PTR ref_data) { NAVBAR_INFO *info = (NAVBAR_INFO *)ref_data; @@ -556,6 +615,7 @@ static LRESULT CALLBACK NAVBAR_PATHEDIT_SubclassProc(HWND hwnd, UINT msg, WPARAM case WM_NCCALCSIZE: return NAVBAR_PATHEDIT_NCCalcSize(hwnd, msg, wparam, lparam); case WM_NCPAINT: return NAVBAR_PATHEDIT_NCPaint(hwnd, msg, wparam, lparam); case WM_NCHITTEST: return NAVBAR_PATHEDIT_NCHitTest(hwnd, msg, wparam, lparam); + case WM_KEYDOWN: return NAVBAR_PATHEDIT_KeyDown(hwnd, info, msg, wparam, lparam); }
return DefSubclassProc(hwnd, msg, wparam, lparam);