[explorer]

- Implement calling IShellView_TranslateAccelerator
- Fixes accelerators like Ctrl+c , Ctrl+v, etc in windows

svn path=/trunk/; revision=57671
This commit is contained in:
Giannis Adamopoulos 2012-11-03 21:00:10 +00:00
parent e9d11b2672
commit db13cd87ac
6 changed files with 73 additions and 18 deletions

View file

@ -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);
}

View file

@ -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();

View file

@ -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);
}

View file

@ -141,6 +141,8 @@ struct ShellBrowser : public IShellBrowserImpl
void invalidate_cache();
bool TranslateAccelerator(LPMSG lpmsg);
protected:
HWND _hwnd;
HWND _hwndFrame;

View file

@ -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;

View file

@ -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().