_Out_ HIMAGELIST *phimlSmall
);
+extern HRESULT IUnknown_ShowDW(IUnknown * punk, BOOL fShow);
+
#include "newatlinterfaces.h"
/*
HRESULT CShellBrowser::Initialize(LPITEMIDLIST pidl, long b, long c, long d)
{
- CComPtr<IDockingWindow> dockingWindow;
- CComPtr<IStream> settingsStream;
CComPtr<IPersistStreamInit> persistStreamInit;
- CComPtr<IOleCommandTarget> commandTarget;
- CComPtr<IObjectWithSite> objectSite;
HRESULT hResult;
+ CComPtr<IUnknown> clientBar;
_AtlInitialConstruct();
if (FAILED(hResult))
return hResult;
#else
- hResult = CreateInternetToolbar(IID_PPV_ARG(IUnknown, &fClientBars[BIInternetToolbar].clientBar));
+ hResult = CreateInternetToolbar(IID_PPV_ARG(IUnknown, &clientBar));
if (FAILED(hResult))
return hResult;
#endif
+ fClientBars[BIInternetToolbar].clientBar = clientBar;
+
// create interfaces
- hResult = fClientBars[BIInternetToolbar].clientBar->QueryInterface(
- IID_PPV_ARG(IDockingWindow, &dockingWindow));
- if (FAILED(hResult))
- return hResult;
- hResult = fClientBars[BIInternetToolbar].clientBar->QueryInterface(
- IID_PPV_ARG(IPersistStreamInit, &persistStreamInit));
- if (FAILED(hResult))
- return hResult;
- hResult = fClientBars[BIInternetToolbar].clientBar->QueryInterface(
- IID_PPV_ARG(IOleCommandTarget, &commandTarget));
- if (FAILED(hResult))
- return hResult;
- hResult = fClientBars[BIInternetToolbar].clientBar->QueryInterface(
- IID_PPV_ARG(IObjectWithSite, &objectSite));
- if (FAILED(hResult))
+ hResult = clientBar->QueryInterface(IID_PPV_ARG(IPersistStreamInit, &persistStreamInit));
+ if (FAILED_UNEXPECTEDLY(hResult))
return hResult;
- hResult = objectSite->SetSite(static_cast<IShellBrowser *>(this));
+ hResult = IUnknown_SetSite(clientBar, static_cast<IShellBrowser *>(this));
if (FAILED(hResult))
return hResult;
- hResult = commandTarget->Exec(&CGID_PrivCITCommands, 1, 1 /* or 0 */, NULL, NULL);
+ hResult = IUnknown_Exec(clientBar, CGID_PrivCITCommands, 1, 1 /* or 0 */, NULL, NULL);
if (FAILED(hResult))
return hResult;
// TODO: create settingsStream from registry entry
- if (settingsStream.p == NULL)
+ //if (settingsStream.p)
+ //{
+ // hResult = persistStreamInit->Load(settingsStream);
+ // if (FAILED_UNEXPECTEDLY(hResult))
+ // return hResult;
+ //}
+ //else
{
hResult = persistStreamInit->InitNew();
if (FAILED(hResult))
return hResult;
}
- else
- {
- hResult = persistStreamInit->Load(settingsStream);
- if (FAILED(hResult))
- return hResult;
- }
- hResult = dockingWindow->ShowDW(TRUE);
- if (FAILED(hResult))
+
+ hResult = IUnknown_ShowDW(clientBar, TRUE);
+ if (FAILED_UNEXPECTEDLY(hResult))
return hResult;
- fToolbarProxy.Initialize(m_hWnd, fClientBars[BIInternetToolbar].clientBar);
+ fToolbarProxy.Initialize(m_hWnd, clientBar);
+
// create status bar
fStatusBar = CreateWindow(STATUSCLASSNAMEW, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
_AtlBaseModule.GetModuleInstance(), 0);
fStatusBarVisible = true;
+
// browse
hResult = BrowseToPIDL(pidl, BTP_UPDATE_NEXT_HISTORY);
if (FAILED(hResult))
CComPtr<IDeskBand> deskBand;
HRESULT hResult;
- if (fClientBars[BIInternetToolbar].clientBar.p == NULL)
- return E_FAIL;
- hResult = fClientBars[BIInternetToolbar].clientBar->QueryInterface(
- IID_PPV_ARG(IServiceProvider, &serviceProvider));
- if (FAILED(hResult))
- return hResult;
- hResult = serviceProvider->QueryService(SID_IBandSite, IID_PPV_ARG(IBandSite, &bandSite));
- if (FAILED(hResult))
+ hResult = IUnknown_QueryService(fClientBars[BIInternetToolbar].clientBar, SID_IBandSite, IID_PPV_ARG(IBandSite, &bandSite));
+ if (FAILED_UNEXPECTEDLY(hResult))
return hResult;
hResult = bandSite->QueryBand(1, &deskBand, NULL, NULL, 0);
if (FAILED(hResult))
CShellBrowser *pThis = reinterpret_cast<CShellBrowser *>(hWnd);
_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
LRESULT lResult;
- CComPtr<IMenuBand> menuBand;
const _ATL_MSG *previousMessage;
BOOL handled;
WNDPROC saveWindowProc;
previousMessage = pThis->m_pCurrentMsg;
pThis->m_pCurrentMsg = &msg;
+ CComPtr<IMenuBand> menuBand;
hResult = pThis->GetMenuBand(IID_PPV_ARG(IMenuBand, &menuBand));
if (SUCCEEDED(hResult) && menuBand.p != NULL)
{
wParam = msg.wParam;
lParam = msg.lParam;
}
+ menuBand.Release();
handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
ATLASSERT(pThis->m_pCurrentMsg == &msg);
CComPtr<IShellMenu> shellMenu;
HRESULT hResult;
- if (IsMenu(hmenuShared) == FALSE)
+ if (hmenuShared && IsMenu(hmenuShared) == FALSE)
return E_FAIL;
hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
if (FAILED(hResult))
HRESULT STDMETHODCALLTYPE CShellBrowser::RemoveMenusSB(HMENU hmenuShared)
{
if (hmenuShared == fCurrentMenuBar)
- fCurrentMenuBar = NULL;
+ {
+ //DestroyMenu(fCurrentMenuBar);
+ SetMenuSB(NULL, NULL, NULL);
+ }
return S_OK;
}
}
template<class T>
-void ReleaseCComPtrExpectZero(CComPtr<T>& cptr)
+void ReleaseCComPtrExpectZero(CComPtr<T>& cptr, BOOL forceRelease = FALSE)
{
if (cptr.p != NULL)
{
if (nrc > 0)
{
DbgPrint("WARNING: Unexpected RefCount > 0!\n");
+ if (forceRelease)
+ {
+ while (nrc > 0)
+ {
+ nrc = cptr->Release();
+ }
+ }
}
cptr.Detach();
}
static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
{
- CComPtr< CComObject<CShellBrowser> > theCabinet;
- HRESULT hResult;
+ CComPtr<CShellBrowser> theCabinet;
+ HRESULT hResult;
MSG Msg;
BOOL Ret;
break;
}
+ if (Msg.message == WM_QUIT)
+ break;
+
if (theCabinet->v_MayTranslateAccelerator(&Msg) != S_OK)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
-
- if (Msg.message == WM_QUIT)
- break;
}
//TerminateProcess(GetCurrentProcess(), hResult);
int nrc = theCabinet->Release();
if (nrc > 0)
{
- DbgPrint("WARNING: There are %d references to the CShellBrowser active or leaked, process will never terminate.\n");
+ DbgPrint("WARNING: There are %d references to the CShellBrowser active or leaked, process will never terminate. Terminating forcefully.\n", nrc);
+
+ //TerminateProcess(GetCurrentProcess(), 1);
}
theCabinet.Detach();