From: Vladislav Timonin timoninvlad@yandex.ru
To be able to Backspace multiple times.
On Windows, Back/Forward/Up/Refresh buttons don't take focus when clicked on, but we do, workaround this by sending Go Up command on Backspace ourselves. --- dlls/comdlg32/itemdlg.c | 12 ++++++++++++ dlls/comdlg32/navbar.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+)
diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 04418fb6eba..c5507a84945 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -3476,7 +3476,19 @@ static HRESULT WINAPI IExplorerBrowserEvents_fnOnNavigationComplete(IExplorerBro if (!hwnd) ERR("Failed to update navbar.\n"); else + { + IShellView *shellview; + HWND shellview_hwnd; + SendMessageW(hwnd, NBM_SETPIDL, 0, (LPARAM)pidlFolder); + + /* keep focus on the explorer browser to be able to Backspace multiple times */ + hr = IExplorerBrowser_GetCurrentView(This->peb, &IID_IShellView, (void**)&shellview); + if (SUCCEEDED(hr)) + hr = IShellView_GetWindow(shellview, &shellview_hwnd); + if (SUCCEEDED(hr)) + SetFocus(shellview_hwnd); + } }
events_OnFolderChange(This); diff --git a/dlls/comdlg32/navbar.c b/dlls/comdlg32/navbar.c index ab8e96a8064..3006c3c691e 100644 --- a/dlls/comdlg32/navbar.c +++ b/dlls/comdlg32/navbar.c @@ -692,6 +692,17 @@ static LRESULT NAVBAR_OVERFLOW_DrawIcon(HWND hwnd, NAVBAR_INFO *info, UINT msg, return DefWindowProcW(hwnd, msg, wparam, lparam); }
+static LRESULT CALLBACK NAVBAR_BackspaceProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT_PTR id_subclass, DWORD_PTR ref_data) +{ + NAVBAR_INFO *info = (NAVBAR_INFO *)ref_data; + + if (msg == WM_KEYDOWN && wparam == VK_BACK && !IsWindowVisible(info->pathedit_hwnd)) + /* match navigation direction with ShellView_OnNotify */ + SendMessageW(info->container_hwnd, WM_COMMAND, IDC_NAVUP, (LPARAM)hwnd); + + return DefSubclassProc(hwnd, msg, wparam, lparam); +} + static LRESULT CALLBACK NAVBAR_BACKGROUND_SubclassProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT_PTR id_subclass, DWORD_PTR ref_data) { NAVBAR_INFO *info = (NAVBAR_INFO *)ref_data; @@ -943,6 +954,7 @@ static LRESULT NAVBAR_Create(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) SendMessageW(info->back_btn_hwnd, WM_SETFONT, (WPARAM)gui_font, FALSE); set_icon(info->icons, ILI_BACK, info->back_btn_hwnd); set_title_and_add_tooltip(info, info->back_btn_hwnd, IDS_BACK); + SetWindowSubclass(info->back_btn_hwnd, NAVBAR_BackspaceProc, 0, (DWORD_PTR)info);
x += cs->cy + 1; info->fwd_btn_hwnd = CreateWindowExW(0, WC_BUTTONW, NULL, @@ -952,6 +964,7 @@ static LRESULT NAVBAR_Create(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) SendMessageW(info->fwd_btn_hwnd, WM_SETFONT, (WPARAM)gui_font, FALSE); set_icon(info->icons, ILI_FORWARD, info->fwd_btn_hwnd); set_title_and_add_tooltip(info, info->fwd_btn_hwnd, IDS_FORWARD); + SetWindowSubclass(info->fwd_btn_hwnd, NAVBAR_BackspaceProc, 0, (DWORD_PTR)info);
x += cs->cy + 1; info->up_btn_hwnd = CreateWindowExW(0, WC_BUTTONW, NULL, @@ -961,6 +974,7 @@ static LRESULT NAVBAR_Create(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) SendMessageW(info->up_btn_hwnd, WM_SETFONT, (WPARAM)gui_font, FALSE); set_icon(info->icons, ILI_UP, info->up_btn_hwnd); set_title_and_add_tooltip(info, info->up_btn_hwnd, IDS_UPFOLDER); + SetWindowSubclass(info->up_btn_hwnd, NAVBAR_BackspaceProc, 0, (DWORD_PTR)info);
x += cs->cy + 1; info->background_hwnd = CreateWindowExW(0, WC_STATICW, NULL, @@ -1000,6 +1014,7 @@ static LRESULT NAVBAR_Create(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) set_icon(info->icons, ILI_REFRESH, info->refresh_goto_btn_hwnd); set_title_and_add_tooltip(info, info->refresh_goto_btn_hwnd, IDS_REFRESH); SetWindowSubclass(info->refresh_goto_btn_hwnd, NAVBAR_REFRESHGOTO_SubclassProc, 0, (DWORD_PTR)info); + SetWindowSubclass(info->refresh_goto_btn_hwnd, NAVBAR_BackspaceProc, 1, (DWORD_PTR)info);
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)info);