CComPtr<IExplorerToolbar> fExplorerToolbar;
public:
void Initialize(HWND parent, IUnknown *explorerToolbar);
-
+ void Destroy();
private:
// message handlers
}
}
+void CToolbarProxy::Destroy()
+{
+ DestroyWindow();
+ fExplorerToolbar = NULL;
+}
+
LRESULT CToolbarProxy::OnAddBitmap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
long int result;
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,
LRESULT OnGoUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
LRESULT OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
LRESULT OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
- LRESULT OnIsThisLegal(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
LRESULT OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
LRESULT OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
LRESULT OnToggleToolbarLock(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnGoUpLevel)
COMMAND_ID_HANDLER(IDM_GOTO_HOMEPAGE, OnGoHome)
COMMAND_ID_HANDLER(IDM_FAVORITES_ORGANIZEFAVORITES, OnOrganizeFavorites)
- COMMAND_ID_HANDLER(IDM_HELP_ISTHISCOPYLEGAL, OnIsThisLegal)
COMMAND_ID_HANDLER(IDM_VIEW_STATUSBAR, OnToggleStatusBarVisible)
COMMAND_ID_HANDLER(IDM_TOOLBARS_LOCKTOOLBARS, OnToggleToolbarLock)
COMMAND_ID_HANDLER(IDM_TOOLBARS_STANDARDBUTTONS, OnToggleToolbarBandVisible)
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;
if (FAILED_UNEXPECTEDLY(hResult))
return hResult;
+ if ((dwFlags & SBSP_EXPLOREMODE) != NULL)
+ ShowBand(CLSID_ExplorerBand, true);
+
ShowWindow(SW_SHOWNORMAL);
return S_OK;
HIMAGELIST himlSmall, himlLarge;
CComPtr<IShellFolder> sf;
- SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
-
- index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
+ hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
+ if (SUCCEEDED(hResult))
+ {
+ index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
- Shell_GetImageLists(&himlLarge, &himlSmall);
+ Shell_GetImageLists(&himlLarge, &himlSmall);
- HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
- HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
+ HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
+ HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
- /* Hack to make it possible to release the old icons */
- /* Something seems to go wrong with WM_SETICON */
- HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
- HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
+ /* Hack to make it possible to release the old icons */
+ /* Something seems to go wrong with WM_SETICON */
+ HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
+ HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
- SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
- SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
+ SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
+ SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
- DestroyIcon(oldSmall);
- DestroyIcon(oldLarge);
+ DestroyIcon(oldSmall);
+ DestroyIcon(oldLarge);
+ }
}
FireCommandStateChangeAll();
// we have to store our basebar into cache now
*cache = newBaseBar;
+ newBaseBar->AddRef();
// tell the new base bar about the shell browser
hResult = IUnknown_SetSite(newBaseBar, static_cast<IDropTarget *>(this));
HRESULT STDMETHODCALLTYPE CShellBrowser::BrowseObject(LPCITEMIDLIST pidl, UINT wFlags)
{
+ if ((wFlags & SBSP_EXPLOREMODE) != NULL)
+ ShowBand(CLSID_ExplorerBand, true);
+
return BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
}
LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
HRESULT hr;
+
+ /* The current thread is about to go down so render any IDataObject that may be left in the clipboard */
+ OleFlushClipboard();
+
// TODO: rip down everything
{
+ fToolbarProxy.Destroy();
+
fCurrentShellView->DestroyViewWindow();
fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
- ReleaseCComPtrExpectZero(fCurrentShellView);
for (int i = 0; i < 3; i++)
{
}
}
pdw->CloseDW(0);
+
+ pClient = NULL;
+ pBarSite = NULL;
pdw = NULL;
- /* For some reasons, it's like we miss some AddRef in ATL when QueryInterface on
- * same interface or inherited one, so we are removing already removed (!) object.
- * TODO: check with MSVC's ATL to see if this behaviour happens too
- */
- bar.Detach();
- pClient.Detach();
- pBarSite.Detach();
+ bar = NULL;
ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
}
+ ReleaseCComPtrExpectZero(fCurrentShellView);
ReleaseCComPtrExpectZero(fTravelLog);
fCurrentShellFolder.Release();
return 0;
}
-LRESULT CShellBrowser::OnIsThisLegal(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
-{
- /* TODO: Implement properly */
-
- LPCWSTR strSite = L"https://www.reactos.org/user-faq";
-
- /* TODO: Make localizable */
- LPCWSTR strCaption = L"Sorry";
- LPCWSTR strMessage = L"ReactOS could not browse to '%s' (error %d). Please make sure there is a web browser installed.";
- WCHAR tmpMessage[512];
-
- /* TODO: Read from the registry */
- LPCWSTR strVerb = NULL; /* default */
- LPCWSTR strPath = strSite;
- LPCWSTR strParams = NULL;
-
- /* The return value is defined as HINSTANCE for backwards compatibility only, the cast is needed */
- int result = (int) ShellExecuteW(m_hWnd, strVerb, strPath, strParams, NULL, SW_SHOWNORMAL);
- if (result <= 32)
- {
- StringCchPrintfW(tmpMessage, 512, strMessage, strSite, result);
- MessageBoxExW(m_hWnd, tmpMessage, strCaption, MB_OK, 0);
- }
-
- return 0;
-}
-
LRESULT CShellBrowser::OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
{
fStatusBarVisible = !fStatusBarVisible;
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 CShellBrowser_CreateInstance(LPITEMIDLIST pidl, DWORD dwFlags, REFIID riid, void **ppv)
{
- HRESULT hr;
- IEThreadParamBlock * parameters = (IEThreadParamBlock *) lpThreadParameter;
-
- OleInitialize(NULL);
-
- ATLTRY(hr = ExplorerMessageLoop(parameters));
-
- OleUninitialize();
-
- SHDestroyIETHREADPARAM(parameters);
-
- return hr;
+ return ShellObjectCreatorInit<CShellBrowser>(pidl, dwFlags, riid, ppv);
}