Author: gadamopoulos
Date: Fri Nov 4 23:56:02 2016
New Revision: 73129
URL:
http://svn.reactos.org/svn/reactos?rev=73129&view=rev
Log:
[BROWSEUI]
- CShellBrowser: Add a standard ShellObjectCreatorInit constructor and make its
initializer take a pidl and flags.
- Move BrowserThreadProc to desktopipc.cpp where the lifetime of the browser thread will
be managed.
Modified:
trunk/reactos/dll/win32/browseui/browseui.h
trunk/reactos/dll/win32/browseui/desktopipc.cpp
trunk/reactos/dll/win32/browseui/shellbrowser.cpp
Modified: trunk/reactos/dll/win32/browseui/browseui.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/browseu…
==============================================================================
--- trunk/reactos/dll/win32/browseui/browseui.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/browseui.h [iso-8859-1] Fri Nov 4 23:56:02 2016
@@ -10,6 +10,7 @@
#define USE_CUSTOM_INTERNETTOOLBAR 1
/* Constructors for the classes that are not exported */
+HRESULT CShellBrowser_CreateInstance(LPITEMIDLIST pidl, DWORD dwFlags, REFIID riid, void
**ppv);
HRESULT CTravelLog_CreateInstance(REFIID riid, void **ppv);
HRESULT CBaseBar_CreateInstance(REFIID riid, void **ppv, BOOL vertical);
HRESULT CBaseBarSite_CreateInstance(REFIID riid, void **ppv, BOOL bVertical);
Modified: trunk/reactos/dll/win32/browseui/desktopipc.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/desktop…
==============================================================================
--- trunk/reactos/dll/win32/browseui/desktopipc.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/desktopipc.cpp [iso-8859-1] Fri Nov 4 23:56:02 2016
@@ -27,8 +27,6 @@
UINT pidlSize80;
UINT pathLength;
};
-
-extern DWORD WINAPI BrowserThreadProc(LPVOID lpThreadParameter);
class CProxyDesktop :
public CComObjectRootEx<CComMultiThreadModelNoCS>,
@@ -345,6 +343,70 @@
return params;
}
+
+static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
+{
+ CComPtr<IBrowserService2> browser;
+ HRESULT hResult;
+ MSG Msg;
+ BOOL Ret;
+
+ // Tell the thread ref we are using it.
+ if (parameters && parameters->offsetF8)
+ parameters->offsetF8->AddRef();
+
+ hResult = CShellBrowser_CreateInstance(parameters->directoryPIDL,
parameters->dwFlags, IID_PPV_ARG(IBrowserService2, &browser));
+ if (FAILED_UNEXPECTEDLY(hResult))
+ return hResult;
+
+ while ((Ret = GetMessage(&Msg, NULL, 0, 0)) != 0)
+ {
+ if (Ret == -1)
+ {
+ // Error: continue or exit?
+ break;
+ }
+
+ if (Msg.message == WM_QUIT)
+ break;
+
+ if (browser->v_MayTranslateAccelerator(&Msg) != S_OK)
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
+ }
+
+ int nrc = browser->Release();
+ if (nrc > 0)
+ {
+ DbgPrint("WARNING: There are %d references to the CShellBrowser active or
leaked.\n", nrc);
+ }
+
+ browser.Detach();
+
+ // Tell the thread ref we are not using it anymore.
+ if (parameters && parameters->offsetF8)
+ parameters->offsetF8->Release();
+
+ return hResult;
+}
+
+static DWORD WINAPI BrowserThreadProc(LPVOID lpThreadParameter)
+{
+ IEThreadParamBlock * parameters = (IEThreadParamBlock *) lpThreadParameter;
+
+ OleInitialize(NULL);
+ ExplorerMessageLoop(parameters);
+
+ /* Destroying the parameters releases the thread reference */
+ SHDestroyIETHREADPARAM(parameters);
+
+ OleUninitialize();
+
+ return 0;
+}
+
/*************************************************************************
* SHCreateIETHREADPARAM [BROWSEUI.123]
*/
Modified: trunk/reactos/dll/win32/browseui/shellbrowser.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/shellbr…
==============================================================================
--- trunk/reactos/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] Fri Nov 4 23:56:02
2016
@@ -309,7 +309,7 @@
CShellBrowser();
~CShellBrowser();
- HRESULT Initialize(LPITEMIDLIST pidl, long b, long c, long d);
+ HRESULT Initialize(LPITEMIDLIST pidl, DWORD dwFlags);
public:
HRESULT BrowseToPIDL(LPCITEMIDLIST pidl, long flags);
HRESULT BrowseToPath(IShellFolder *newShellFolder, LPCITEMIDLIST absolutePIDL,
@@ -706,7 +706,7 @@
DSA_Destroy(menuDsa);
}
-HRESULT CShellBrowser::Initialize(LPITEMIDLIST pidl, long b, long c, long d)
+HRESULT CShellBrowser::Initialize(LPITEMIDLIST pidl, DWORD dwFlags)
{
CComPtr<IPersistStreamInit> persistStreamInit;
HRESULT hResult;
@@ -3697,72 +3697,7 @@
return 0;
}
-static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
-{
- CComPtr<CShellBrowser> theCabinet;
- HRESULT hResult;
- MSG Msg;
- BOOL Ret;
-
- // Tell the thread ref we are using it.
- if (parameters && parameters->offsetF8)
- parameters->offsetF8->AddRef();
-
- ATLTRY(theCabinet = new CComObject<CShellBrowser>);
- if (theCabinet == NULL)
- {
- return E_OUTOFMEMORY;
- }
-
- hResult = theCabinet->Initialize(parameters->directoryPIDL, 0, 0, 0);
- if (FAILED_UNEXPECTEDLY(hResult))
- return E_OUTOFMEMORY;
-
- while ((Ret = GetMessage(&Msg, NULL, 0, 0)) != 0)
- {
- if (Ret == -1)
- {
- // Error: continue or exit?
- break;
- }
-
- if (Msg.message == WM_QUIT)
- break;
-
- if (theCabinet->v_MayTranslateAccelerator(&Msg) != S_OK)
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- }
-
- int nrc = theCabinet->Release();
- if (nrc > 0)
- {
- DbgPrint("WARNING: There are %d references to the CShellBrowser active or
leaked.\n", nrc);
- }
-
- theCabinet.Detach();
-
- // Tell the thread ref we are not using it anymore.
- if (parameters && parameters->offsetF8)
- parameters->offsetF8->Release();
-
- return hResult;
-}
-
-DWORD WINAPI BrowserThreadProc(LPVOID lpThreadParameter)
-{
- HRESULT hr;
- IEThreadParamBlock * parameters = (IEThreadParamBlock *) lpThreadParameter;
-
- OleInitialize(NULL);
-
- ATLTRY(hr = ExplorerMessageLoop(parameters));
-
- OleUninitialize();
-
- SHDestroyIETHREADPARAM(parameters);
-
- return hr;
-}
+HRESULT CShellBrowser_CreateInstance(LPITEMIDLIST pidl, DWORD dwFlags, REFIID riid, void
**ppv)
+{
+ return ShellObjectCreatorInit<CShellBrowser>(pidl, dwFlags, riid, ppv);
+}