[BROWSEUI]
authorDavid Quintana <gigaherz@gmail.com>
Wed, 21 May 2014 11:38:29 +0000 (11:38 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Wed, 21 May 2014 11:38:29 +0000 (11:38 +0000)
* 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
dll/win32/shell32/shlview.cpp

index 70e26f9..db6a1f2 100644 (file)
@@ -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<IShellBrowser>                  shellBrowser;
+    CComObject<CShellBrowser>               *theCabinet;
+    HRESULT                                 hResult;
     MSG Msg;
     BOOL Ret;
 
-    while (1)
+    OleInitialize(NULL);
+
+    ATLTRY(theCabinet = new CComObject<CShellBrowser>);
+    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<IShellBrowser>                  shellBrowser;
-    CComObject<CShellBrowser>               *theCabinet;
-    IEThreadParamBlock                      *parameters;
-    HRESULT                                 hResult;
-
-    parameters = (IEThreadParamBlock *)lpThreadParameter;
-    OleInitialize(NULL);
-    ATLTRY (theCabinet = new CComObject<CShellBrowser>);
-    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);
 }
index f1b4b4a..f8bcd86 100644 (file)
@@ -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) ;
     }