From 2defe4fed2907e74c6d042056a378fffcd37d991 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Wed, 21 May 2014 11:38:29 +0000 Subject: [PATCH] [BROWSEUI] * Improve the message loop to allow processing of accelerators. [SHELL32] * Return the accelerator to the shell browser if the view doesn't handle it. svn path=/branches/shell-experiments/; revision=63397 --- dll/win32/browseui/shellbrowser.cpp | 77 +++++++++++++++-------------- dll/win32/shell32/shlview.cpp | 2 + 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index 70e26f941ac..db6a1f24471 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -2528,7 +2528,7 @@ HRESULT STDMETHODCALLTYPE CShellBrowser::_SetFocus(LPTOOLBARITEM ptbi, HWND hwnd HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayTranslateAccelerator(MSG *pmsg) { - return E_NOTIMPL; + return fCurrentShellView->TranslateAcceleratorW(pmsg); } HRESULT STDMETHODCALLTYPE CShellBrowser::_GetBorderDWHelper(IUnknown *punkSrc, LPRECT lprectBorder, BOOL bUseHmonitor) @@ -3272,56 +3272,59 @@ LRESULT CShellBrowser::RelayCommands(UINT uMsg, WPARAM wParam, LPARAM lParam, BO return 0; } -//static LRESULT CALLBACK ExplorerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -//{ -// return DefWindowProc(hwnd, uMsg, wParam, lParam); -//} - -static void ExplorerMessageLoop() +static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters) { + CComPtr shellBrowser; + CComObject *theCabinet; + HRESULT hResult; MSG Msg; BOOL Ret; - while (1) + OleInitialize(NULL); + + ATLTRY(theCabinet = new CComObject); + if (theCabinet == NULL) + { + hResult = E_OUTOFMEMORY; + goto uninitialize; + } + + hResult = theCabinet->QueryInterface(IID_PPV_ARG(IShellBrowser, &shellBrowser)); + if (FAILED(hResult)) { - Ret = (GetMessage(&Msg, NULL, 0, 0) != 0); + delete theCabinet; + goto uninitialize; + } + + hResult = theCabinet->Initialize(parameters->directoryPIDL, 0, 0, 0); + if (FAILED(hResult)) + goto uninitialize; - if (Ret != -1) + while (Ret = GetMessage(&Msg, NULL, 0, 0)) + { + if (Ret == -1) { - if (!Ret) - break; + // Error: continue or exit? + break; + } + if (theCabinet->v_MayTranslateAccelerator(&Msg) != S_OK) + { TranslateMessage(&Msg); DispatchMessage(&Msg); - - if (Msg.message == WM_QUIT) - break; } + + if (Msg.message == WM_QUIT) + break; } + +uninitialize: + OleUninitialize(); + return hResult; } DWORD WINAPI BrowserThreadProc(LPVOID lpThreadParameter) { - CComPtr shellBrowser; - CComObject *theCabinet; - IEThreadParamBlock *parameters; - HRESULT hResult; - - parameters = (IEThreadParamBlock *)lpThreadParameter; - OleInitialize(NULL); - ATLTRY (theCabinet = new CComObject); - if (theCabinet == NULL) - return E_OUTOFMEMORY; - hResult = theCabinet->QueryInterface(IID_PPV_ARG(IShellBrowser, &shellBrowser)); - if (FAILED(hResult)) - { - delete theCabinet; - return hResult; - } - hResult = theCabinet->Initialize(parameters->directoryPIDL, 0, 0, 0); - if (FAILED(hResult)) - return hResult; - ExplorerMessageLoop(); - OleUninitialize(); - return 0; + IEThreadParamBlock * parameters = (IEThreadParamBlock *) lpThreadParameter; + return ExplorerMessageLoop(parameters); } diff --git a/dll/win32/shell32/shlview.cpp b/dll/win32/shell32/shlview.cpp index f1b4b4a0c88..f8bcd8603f7 100644 --- a/dll/win32/shell32/shlview.cpp +++ b/dll/win32/shell32/shlview.cpp @@ -1925,6 +1925,8 @@ HRESULT WINAPI CDefView::TranslateAccelerator(LPMSG lpmsg) /* FIXME: should call TranslateAcceleratorSB */ + return m_pShellBrowser->TranslateAcceleratorSB(lpmsg, 0); + TRACE("-- key=0x04%lx\n", lpmsg->wParam) ; } -- 2.17.1