From db13cd87ac31c62c827e824ebc3f1765f685436b Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 3 Nov 2012 21:00:10 +0000 Subject: [PATCH] [explorer] - Implement calling IShellView_TranslateAccelerator - Fixes accelerators like Ctrl+c , Ctrl+v, etc in windows svn path=/trunk/; revision=57671 --- .../base/shell/explorer/desktop/desktop.cpp | 20 +++++++++++ reactos/base/shell/explorer/desktop/desktop.h | 4 +-- .../shell/explorer/shell/shellbrowser.cpp | 24 ++++++++++++++ .../base/shell/explorer/shell/shellbrowser.h | 2 ++ .../base/shell/explorer/utility/window.cpp | 8 +++++ reactos/base/shell/explorer/utility/window.h | 33 ++++++++++--------- 6 files changed, 73 insertions(+), 18 deletions(-) diff --git a/reactos/base/shell/explorer/desktop/desktop.cpp b/reactos/base/shell/explorer/desktop/desktop.cpp index ed613576fd3..c00308ff00a 100644 --- a/reactos/base/shell/explorer/desktop/desktop.cpp +++ b/reactos/base/shell/explorer/desktop/desktop.cpp @@ -479,6 +479,26 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) SendMessage(g_Globals._hwndShellView, nmsg, wparam, lparam); break; + case PM_TRANSLATE_MSG: + { + /* TranslateAccelerator is called for all explorer windows that are open + so we have to decide if this is the correct recipient */ + LPMSG lpmsg = (LPMSG)lparam; + HWND hwnd = lpmsg->hwnd; + + while(hwnd) + { + if(hwnd == _hwnd) + break; + + hwnd = GetParent(hwnd); + } + + if (hwnd) + return _pShellView->TranslateAccelerator(lpmsg) == S_OK; + return false; + } + default: def: return super::WndProc(nmsg, wparam, lparam); } diff --git a/reactos/base/shell/explorer/desktop/desktop.h b/reactos/base/shell/explorer/desktop/desktop.h index ab46611eb1a..2fffb4cd9f0 100644 --- a/reactos/base/shell/explorer/desktop/desktop.h +++ b/reactos/base/shell/explorer/desktop/desktop.h @@ -48,9 +48,9 @@ protected: /// Implementation of the Explorer desktop window -struct DesktopWindow : public Window, public IShellBrowserImpl +struct DesktopWindow : public PreTranslateWindow, public IShellBrowserImpl { - typedef Window super; + typedef PreTranslateWindow super; DesktopWindow(HWND hwnd); ~DesktopWindow(); diff --git a/reactos/base/shell/explorer/shell/shellbrowser.cpp b/reactos/base/shell/explorer/shell/shellbrowser.cpp index 44ba3750ff0..1c74c86393c 100644 --- a/reactos/base/shell/explorer/shell/shellbrowser.cpp +++ b/reactos/base/shell/explorer/shell/shellbrowser.cpp @@ -599,6 +599,27 @@ bool ShellBrowser::jump_to_pidl(LPCITEMIDLIST pidl) return false; } +bool ShellBrowser::TranslateAccelerator(LPMSG lpmsg) +{ + HWND hwnd; + + /* TranslateAccelerator is called for all explorer windows that are open + so we have to decide if this is the correct recipient */ + hwnd = lpmsg->hwnd; + + while(hwnd) + { + if(hwnd == _hwnd) + break; + + hwnd = GetParent(hwnd); + } + + if (hwnd) + return _pShellView->TranslateAccelerator(lpmsg) == S_OK; + + return false; +} bool ShellBrowser::select_folder(Entry* entry, bool expand) { @@ -707,6 +728,9 @@ LRESULT MDIShellBrowserChild::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) SendMessage(_right_hwnd, WM_SYSCOLORCHANGE, 0, 0); break; + case PM_TRANSLATE_MSG: + return _shellBrowser->TranslateAccelerator((MSG*)lparam); + default: return super::WndProc(nmsg, wparam, lparam); } diff --git a/reactos/base/shell/explorer/shell/shellbrowser.h b/reactos/base/shell/explorer/shell/shellbrowser.h index 886d5ce24c9..be910f1beb5 100644 --- a/reactos/base/shell/explorer/shell/shellbrowser.h +++ b/reactos/base/shell/explorer/shell/shellbrowser.h @@ -141,6 +141,8 @@ struct ShellBrowser : public IShellBrowserImpl void invalidate_cache(); + bool TranslateAccelerator(LPMSG lpmsg); + protected: HWND _hwnd; HWND _hwndFrame; diff --git a/reactos/base/shell/explorer/utility/window.cpp b/reactos/base/shell/explorer/utility/window.cpp index 4ad750f7a8c..bb0814d07ef 100644 --- a/reactos/base/shell/explorer/utility/window.cpp +++ b/reactos/base/shell/explorer/utility/window.cpp @@ -591,6 +591,14 @@ void Window::unregister_pretranslate(HWND hwnd) BOOL Window::pretranslate_msg(LPMSG pmsg) { + if ((pmsg->message != WM_KEYDOWN) && + (pmsg->message != WM_SYSKEYDOWN) && + (pmsg->message != WM_SYSCHAR) && + (pmsg->message != WM_CHAR)) + { + return FALSE; + } + for(WindowSet::const_iterator it=Window::s_pretranslate_windows.begin(); it!=s_pretranslate_windows.end(); ++it) if (SendMessage(*it, PM_TRANSLATE_MSG, 0, (LPARAM)pmsg)) return TRUE; diff --git a/reactos/base/shell/explorer/utility/window.h b/reactos/base/shell/explorer/utility/window.h index 3f556b956db..3bf913adfbc 100644 --- a/reactos/base/shell/explorer/utility/window.h +++ b/reactos/base/shell/explorer/utility/window.h @@ -282,13 +282,28 @@ struct MenuInfo #define Frame_GetMenuInfo(hwnd) ((MenuInfo*)SNDMSG(hwnd, PM_FRM_GET_MENUINFO, 0, 0)) + /** + PreTranslateWindow is used to register windows to be called by Window::pretranslate_msg(). + This way you get PM_TRANSLATE_MSG messages before the message loop dispatches messages. + You can then for example use TranslateAccelerator() to implement key shortcuts. + */ +struct PreTranslateWindow : public Window +{ + typedef Window super; + + PreTranslateWindow(HWND); + ~PreTranslateWindow(); +}; + + + /** Class ChildWindow represents MDI child windows. It is used with class MainFrame. */ -struct ChildWindow : public Window +struct ChildWindow : public PreTranslateWindow { - typedef Window super; + typedef PreTranslateWindow super; ChildWindow(HWND hwnd, const ChildWndInfo& info); @@ -325,20 +340,6 @@ protected: #define PM_SETSTATUSTEXT (WM_APP+0x1E) - /** - PreTranslateWindow is used to register windows to be called by Window::pretranslate_msg(). - This way you get PM_TRANSLATE_MSG messages before the message loop dispatches messages. - You can then for example use TranslateAccelerator() to implement key shortcuts. - */ -struct PreTranslateWindow : public Window -{ - typedef Window super; - - PreTranslateWindow(HWND); - ~PreTranslateWindow(); -}; - - /** The class DialogWindow implements modeless dialogs, which are managed by Window::dispatch_dialog_msg() in Window::MessageLoop().