mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[RSHELL]
* Use the debugging class to track COM refcounting of the CMenuBand. * CMenuSite: Remove an useless line. [BROWSEUI] * Refactor the CreateMenuBar method in an attempt to figure out a seemingly magic crash with VS2010 (not yet solved). * Begin fixing some unused-but-set warnings. [SHELL32] * Fix some small bugs spotted by Victor. svn path=/branches/shell-experiments/; revision=63546
This commit is contained in:
parent
9f33eab100
commit
7ddd2648be
10 changed files with 167 additions and 71 deletions
|
@ -44,7 +44,7 @@ HRESULT WINAPI CMenuBand_Constructor(REFIID riid, LPVOID *ppv)
|
||||||
#else
|
#else
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
|
|
||||||
CMenuBand * site = new CComObject<CMenuBand>();
|
CMenuBand * site = new CComDebugObject<CMenuBand>();
|
||||||
|
|
||||||
if (!site)
|
if (!site)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
|
@ -354,7 +354,6 @@ BOOL CMenuSite::ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
RECT Rect = { 0 };
|
RECT Rect = { 0 };
|
||||||
GetClientRect(&Rect);
|
GetClientRect(&Rect);
|
||||||
Rect.right = Rect.right;
|
|
||||||
pMenuPopup->OnPosRectChangeDB(&Rect);
|
pMenuPopup->OnPosRectChangeDB(&Rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,3 +113,75 @@ Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
|
||||||
#else
|
#else
|
||||||
#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
|
#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
template <class Base>
|
||||||
|
class CComDebugObject : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CComDebugObject(void * = NULL)
|
||||||
|
{
|
||||||
|
_pAtlModule->Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CComDebugObject()
|
||||||
|
{
|
||||||
|
this->FinalRelease();
|
||||||
|
_pAtlModule->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHOD_(ULONG, AddRef)()
|
||||||
|
{
|
||||||
|
int rc = this->InternalAddRef();
|
||||||
|
DbgPrint("RefCount is now %d(++)!\n", rc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHOD_(ULONG, Release)()
|
||||||
|
{
|
||||||
|
ULONG newRefCount;
|
||||||
|
|
||||||
|
newRefCount = this->InternalRelease();
|
||||||
|
DbgPrint("RefCount is now %d(--)!\n", newRefCount);
|
||||||
|
if (newRefCount == 0)
|
||||||
|
delete this;
|
||||||
|
return newRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
|
||||||
|
{
|
||||||
|
return this->_InternalQueryInterface(iid, ppvObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI CreateInstance(CComDebugObject<Base> **pp)
|
||||||
|
{
|
||||||
|
CComDebugObject<Base> *newInstance;
|
||||||
|
HRESULT hResult;
|
||||||
|
|
||||||
|
ATLASSERT(pp != NULL);
|
||||||
|
if (pp == NULL)
|
||||||
|
return E_POINTER;
|
||||||
|
|
||||||
|
hResult = E_OUTOFMEMORY;
|
||||||
|
newInstance = NULL;
|
||||||
|
ATLTRY(newInstance = new CComDebugObject<Base>())
|
||||||
|
if (newInstance != NULL)
|
||||||
|
{
|
||||||
|
newInstance->SetVoid(NULL);
|
||||||
|
newInstance->InternalFinalConstructAddRef();
|
||||||
|
hResult = newInstance->_AtlInitialConstruct();
|
||||||
|
if (SUCCEEDED(hResult))
|
||||||
|
hResult = newInstance->FinalConstruct();
|
||||||
|
if (SUCCEEDED(hResult))
|
||||||
|
hResult = newInstance->_AtlFinalConstruct();
|
||||||
|
newInstance->InternalFinalConstructRelease();
|
||||||
|
if (hResult != S_OK)
|
||||||
|
{
|
||||||
|
delete newInstance;
|
||||||
|
newInstance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*pp = newInstance;
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -547,9 +547,11 @@ CInternetToolbar::CInternetToolbar()
|
||||||
fLocked = false;
|
fLocked = false;
|
||||||
fMenuBandWindow = NULL;
|
fMenuBandWindow = NULL;
|
||||||
fNavigationWindow = NULL;
|
fNavigationWindow = NULL;
|
||||||
fMenuCallback.AddRef();
|
fMenuCallback = new CComDebugObject<CMenuCallback>();
|
||||||
fToolbarWindow = NULL;
|
fToolbarWindow = NULL;
|
||||||
fAdviseCookie = 0;
|
fAdviseCookie = 0;
|
||||||
|
|
||||||
|
fMenuCallback->AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
CInternetToolbar::~CInternetToolbar()
|
CInternetToolbar::~CInternetToolbar()
|
||||||
|
@ -585,73 +587,77 @@ HRESULT CInternetToolbar::ReserveBorderSpace(LONG maxHeight)
|
||||||
return ResizeBorderDW(&availableBorderSpace, fSite, FALSE);
|
return ResizeBorderDW(&availableBorderSpace, fSite, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
|
HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **pMenuBar)
|
||||||
{
|
{
|
||||||
CComPtr<IOleCommandTarget> siteCommandTarget;
|
CComPtr<IShellMenu> menubar;
|
||||||
CComPtr<IOleWindow> oleWindow;
|
|
||||||
CComPtr<IOleCommandTarget> commandTarget;
|
|
||||||
CComPtr<IShellMenuCallback> callback;
|
CComPtr<IShellMenuCallback> callback;
|
||||||
VARIANT menuOut;
|
VARIANT menuOut;
|
||||||
HWND ownerWindow;
|
HWND ownerWindow;
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
|
if (!pMenuBar)
|
||||||
|
return E_POINTER;
|
||||||
|
|
||||||
|
|
||||||
|
*pMenuBar = NULL;
|
||||||
|
|
||||||
|
hResult = E_FAIL;
|
||||||
#if USE_CUSTOM_MENUBAND
|
#if USE_CUSTOM_MENUBAND
|
||||||
HMODULE hrs = LoadLibraryW(L"rshell.dll");
|
HMODULE hrs = GetModuleHandleW(L"rshell.dll");
|
||||||
|
|
||||||
if (!hrs)
|
|
||||||
{
|
|
||||||
DbgPrint("Failed: %d\n", GetLastError());
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
|
|
||||||
if (func)
|
|
||||||
{
|
|
||||||
hResult = func(IID_PPV_ARG(IShellMenu, menuBar));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DbgPrint("Failed: %d\n", GetLastError());
|
|
||||||
hResult = E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!hrs) hrs = LoadLibraryW(L"rshell.dll");
|
||||||
|
|
||||||
|
if (hrs)
|
||||||
|
{
|
||||||
|
PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
|
||||||
|
if (func)
|
||||||
|
{
|
||||||
|
hResult = func(IID_PPV_ARG(IShellMenu, &menubar));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
menubar->AddRef();
|
||||||
|
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
{
|
{
|
||||||
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
|
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
|
||||||
IID_PPV_ARG(IShellMenu, menuBar));
|
IID_PPV_ARG(IShellMenu, &menubar));
|
||||||
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
|
return hResult;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
|
hResult = fMenuCallback->QueryInterface(IID_PPV_ARG(IShellMenuCallback, &callback));
|
||||||
IID_PPV_ARG(IShellMenu, menuBar));
|
|
||||||
#endif
|
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
return hResult;
|
return hResult;
|
||||||
hResult = fMenuCallback.QueryInterface(IID_PPV_ARG(IShellMenuCallback, &callback));
|
|
||||||
|
hResult = menubar->Initialize(callback, -1, ANCESTORDEFAULT, SMINIT_HORIZONTAL | SMINIT_TOPLEVEL);
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
return hResult;
|
return hResult;
|
||||||
hResult = (*menuBar)->Initialize(callback, -1, ANCESTORDEFAULT, SMINIT_HORIZONTAL | SMINIT_TOPLEVEL);
|
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
// Set Menu
|
||||||
return hResult;
|
{
|
||||||
hResult = fSite->QueryInterface(IID_PPV_ARG(IOleWindow, &oleWindow));
|
hResult = IUnknown_Exec(fSite, CGID_Explorer, 0x35, 0, NULL, &menuOut);
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
return hResult;
|
return hResult;
|
||||||
hResult = oleWindow->GetWindow(&ownerWindow);
|
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (V_VT(&menuOut) != VT_INT_PTR || V_INTREF(&menuOut) == NULL)
|
||||||
return hResult;
|
return E_FAIL;
|
||||||
hResult = fSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &siteCommandTarget));
|
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
hResult = IUnknown_GetWindow(fSite, &ownerWindow);
|
||||||
return hResult;
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
hResult = siteCommandTarget->Exec(&CGID_Explorer, 0x35, 0, NULL, &menuOut);
|
return hResult;
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
|
||||||
return hResult;
|
hResult = menubar->SetMenu((HMENU) V_INTREF(&menuOut), ownerWindow, SMSET_DONTOWN);
|
||||||
if (V_VT(&menuOut) != VT_INT_PTR || V_INTREF(&menuOut) == NULL)
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
return E_FAIL;
|
return hResult;
|
||||||
hResult = (*menuBar)->SetMenu((HMENU)V_INTREF(&menuOut), ownerWindow, SMSET_DONTOWN);
|
}
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
|
||||||
return hResult;
|
hResult = IUnknown_Exec(menubar, CGID_MenuBand, 3, 1, NULL, NULL);
|
||||||
hResult = IUnknown_Exec(*menuBar, CGID_MenuBand, 3, 1, NULL, NULL);
|
|
||||||
if (FAILED_UNEXPECTEDLY(hResult))
|
if (FAILED_UNEXPECTEDLY(hResult))
|
||||||
return hResult;
|
return hResult;
|
||||||
|
|
||||||
|
*pMenuBar = menubar.Detach();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1686,7 +1692,7 @@ LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam,
|
||||||
mii.cbSize = sizeof(mii);
|
mii.cbSize = sizeof(mii);
|
||||||
mii.fMask = MIIM_STATE;
|
mii.fMask = MIIM_STATE;
|
||||||
mii.fState = fLocked ? MFS_CHECKED : MFS_UNCHECKED;
|
mii.fState = fLocked ? MFS_CHECKED : MFS_UNCHECKED;
|
||||||
command = SetMenuItemInfo(contextMenu, IDM_TOOLBARS_LOCKTOOLBARS, FALSE, &mii);
|
SetMenuItemInfo(contextMenu, IDM_TOOLBARS_LOCKTOOLBARS, FALSE, &mii);
|
||||||
|
|
||||||
// TODO: use GetSystemMetrics(SM_MENUDROPALIGNMENT) to determine menu alignment
|
// TODO: use GetSystemMetrics(SM_MENUDROPALIGNMENT) to determine menu alignment
|
||||||
command = TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
command = TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
CComPtr<IUnknown> fLogoBar; // the reactos logo
|
CComPtr<IUnknown> fLogoBar; // the reactos logo
|
||||||
CComPtr<IUnknown> fControlsBar; // navigation controls
|
CComPtr<IUnknown> fControlsBar; // navigation controls
|
||||||
CComPtr<IUnknown> fNavigationBar; // address bar
|
CComPtr<IUnknown> fNavigationBar; // address bar
|
||||||
CComObject<CMenuCallback> fMenuCallback;
|
CComPtr<CMenuCallback> fMenuCallback;
|
||||||
CComPtr<IOleCommandTarget> fCommandTarget;
|
CComPtr<IOleCommandTarget> fCommandTarget;
|
||||||
GUID fCommandCategory;
|
GUID fCommandCategory;
|
||||||
HWND fToolbarWindow;
|
HWND fToolbarWindow;
|
||||||
|
|
|
@ -903,10 +903,21 @@ HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10,
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
|
|
||||||
hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
|
hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
return hResult;
|
||||||
|
|
||||||
hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
|
hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
return hResult;
|
||||||
|
|
||||||
StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
|
StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
|
||||||
if (rgfInOut)
|
if (rgfInOut)
|
||||||
|
{
|
||||||
hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
|
hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
ILFree(childPIDL);
|
ILFree(childPIDL);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule,
|
||||||
PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam;
|
PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam;
|
||||||
|
|
||||||
if (IS_INTRESOURCE(lpszName))
|
if (IS_INTRESOURCE(lpszName))
|
||||||
swprintf(szName, L"%u", lpszName);
|
swprintf(szName, L"%u", (DWORD)lpszName);
|
||||||
else
|
else
|
||||||
wcscpy(szName, (WCHAR*)lpszName);
|
wcscpy(szName, (WCHAR*)lpszName);
|
||||||
|
|
||||||
|
|
|
@ -753,11 +753,13 @@ EXTERN_C LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl)
|
||||||
*/
|
*/
|
||||||
UINT WINAPI ILGetSize(LPCITEMIDLIST pidl)
|
UINT WINAPI ILGetSize(LPCITEMIDLIST pidl)
|
||||||
{
|
{
|
||||||
LPCSHITEMID si = &(pidl->mkid);
|
LPCSHITEMID si;
|
||||||
UINT len = 0;
|
UINT len = 0;
|
||||||
|
|
||||||
if (pidl)
|
if (pidl)
|
||||||
{
|
{
|
||||||
|
si = &(pidl->mkid);
|
||||||
|
|
||||||
while (si->cb)
|
while (si->cb)
|
||||||
{
|
{
|
||||||
len += si->cb;
|
len += si->cb;
|
||||||
|
|
|
@ -752,7 +752,7 @@ DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
|
||||||
temppsfi.dwAttributes=psfi->dwAttributes;
|
temppsfi.dwAttributes=psfi->dwAttributes;
|
||||||
|
|
||||||
if (psfi == NULL)
|
if (psfi == NULL)
|
||||||
ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, sizeof(temppsfi), flags);
|
ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
|
||||||
else
|
else
|
||||||
ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
|
ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
|
||||||
|
|
||||||
|
|
|
@ -126,35 +126,41 @@ HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
|
||||||
LPITEMIDLIST * pidlInOut, LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes)
|
LPITEMIDLIST * pidlInOut, LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes)
|
||||||
{
|
{
|
||||||
HRESULT hr = E_INVALIDARG;
|
HRESULT hr = E_INVALIDARG;
|
||||||
LPITEMIDLIST pidlOut = NULL,
|
LPITEMIDLIST pidlIn = pidlInOut ? *pidlInOut : NULL;
|
||||||
pidlTemp = NULL;
|
LPITEMIDLIST pidlOut = NULL;
|
||||||
IShellFolder *psfChild;
|
LPITEMIDLIST pidlTemp = NULL;
|
||||||
|
CComPtr<IShellFolder> psfChild;
|
||||||
|
|
||||||
TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlInOut ? *pidlInOut : NULL, debugstr_w (szNext));
|
TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlIn, debugstr_w (szNext));
|
||||||
|
|
||||||
/* get the shellfolder for the child pidl and let it analyse further */
|
/* get the shellfolder for the child pidl and let it analyse further */
|
||||||
hr = psf->BindToObject(*pidlInOut, pbc, IID_PPV_ARG(IShellFolder, &psfChild));
|
hr = psf->BindToObject(pidlIn, pbc, IID_PPV_ARG(IShellFolder, &psfChild));
|
||||||
|
if (FAILED(hr))
|
||||||
|
return hr;
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
hr = psfChild->ParseDisplayName(hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes);
|
hr = psfChild->ParseDisplayName(hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes);
|
||||||
psfChild->Release();
|
if (FAILED(hr))
|
||||||
|
return hr;
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
pidlTemp = ILCombine (pidlIn, pidlOut);
|
||||||
pidlTemp = ILCombine (*pidlInOut, pidlOut);
|
if (!pidlTemp)
|
||||||
|
{
|
||||||
if (!pidlTemp)
|
|
||||||
hr = E_OUTOFMEMORY;
|
hr = E_OUTOFMEMORY;
|
||||||
|
if (pidlOut)
|
||||||
|
ILFree(pidlOut);
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pidlOut)
|
if (pidlOut)
|
||||||
ILFree (pidlOut);
|
ILFree (pidlOut);
|
||||||
}
|
|
||||||
|
|
||||||
ILFree (*pidlInOut);
|
if (pidlIn)
|
||||||
|
ILFree (pidlIn);
|
||||||
|
|
||||||
*pidlInOut = pidlTemp;
|
*pidlInOut = pidlTemp;
|
||||||
|
|
||||||
TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
|
TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
|
||||||
return hr;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
Loading…
Reference in a new issue