mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +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
|
||||
*ppv = NULL;
|
||||
|
||||
CMenuBand * site = new CComObject<CMenuBand>();
|
||||
CMenuBand * site = new CComDebugObject<CMenuBand>();
|
||||
|
||||
if (!site)
|
||||
return E_OUTOFMEMORY;
|
||||
|
|
|
@ -354,7 +354,6 @@ BOOL CMenuSite::ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
{
|
||||
RECT Rect = { 0 };
|
||||
GetClientRect(&Rect);
|
||||
Rect.right = Rect.right;
|
||||
pMenuPopup->OnPosRectChangeDB(&Rect);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,3 +113,75 @@ Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
|
|||
#else
|
||||
#define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
|
||||
#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;
|
||||
fMenuBandWindow = NULL;
|
||||
fNavigationWindow = NULL;
|
||||
fMenuCallback.AddRef();
|
||||
fMenuCallback = new CComDebugObject<CMenuCallback>();
|
||||
fToolbarWindow = NULL;
|
||||
fAdviseCookie = 0;
|
||||
|
||||
fMenuCallback->AddRef();
|
||||
}
|
||||
|
||||
CInternetToolbar::~CInternetToolbar()
|
||||
|
@ -585,73 +587,77 @@ HRESULT CInternetToolbar::ReserveBorderSpace(LONG maxHeight)
|
|||
return ResizeBorderDW(&availableBorderSpace, fSite, FALSE);
|
||||
}
|
||||
|
||||
HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
|
||||
HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **pMenuBar)
|
||||
{
|
||||
CComPtr<IOleCommandTarget> siteCommandTarget;
|
||||
CComPtr<IOleWindow> oleWindow;
|
||||
CComPtr<IOleCommandTarget> commandTarget;
|
||||
CComPtr<IShellMenu> menubar;
|
||||
CComPtr<IShellMenuCallback> callback;
|
||||
VARIANT menuOut;
|
||||
HWND ownerWindow;
|
||||
HRESULT hResult;
|
||||
if (!pMenuBar)
|
||||
return E_POINTER;
|
||||
|
||||
|
||||
*pMenuBar = NULL;
|
||||
|
||||
hResult = E_FAIL;
|
||||
#if USE_CUSTOM_MENUBAND
|
||||
HMODULE hrs = LoadLibraryW(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;
|
||||
}
|
||||
HMODULE hrs = GetModuleHandleW(L"rshell.dll");
|
||||
|
||||
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))
|
||||
{
|
||||
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,
|
||||
IID_PPV_ARG(IShellMenu, menuBar));
|
||||
#endif
|
||||
|
||||
hResult = fMenuCallback->QueryInterface(IID_PPV_ARG(IShellMenuCallback, &callback));
|
||||
if (FAILED_UNEXPECTEDLY(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))
|
||||
return hResult;
|
||||
hResult = (*menuBar)->Initialize(callback, -1, ANCESTORDEFAULT, SMINIT_HORIZONTAL | SMINIT_TOPLEVEL);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
hResult = fSite->QueryInterface(IID_PPV_ARG(IOleWindow, &oleWindow));
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
hResult = oleWindow->GetWindow(&ownerWindow);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
hResult = fSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &siteCommandTarget));
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
hResult = siteCommandTarget->Exec(&CGID_Explorer, 0x35, 0, NULL, &menuOut);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
if (V_VT(&menuOut) != VT_INT_PTR || V_INTREF(&menuOut) == NULL)
|
||||
return E_FAIL;
|
||||
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);
|
||||
|
||||
// Set Menu
|
||||
{
|
||||
hResult = IUnknown_Exec(fSite, CGID_Explorer, 0x35, 0, NULL, &menuOut);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
|
||||
if (V_VT(&menuOut) != VT_INT_PTR || V_INTREF(&menuOut) == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
hResult = IUnknown_GetWindow(fSite, &ownerWindow);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
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);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return hResult;
|
||||
|
||||
*pMenuBar = menubar.Detach();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -1686,7 +1692,7 @@ LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam,
|
|||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
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
|
||||
command = TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
CComPtr<IUnknown> fLogoBar; // the reactos logo
|
||||
CComPtr<IUnknown> fControlsBar; // navigation controls
|
||||
CComPtr<IUnknown> fNavigationBar; // address bar
|
||||
CComObject<CMenuCallback> fMenuCallback;
|
||||
CComPtr<CMenuCallback> fMenuCallback;
|
||||
CComPtr<IOleCommandTarget> fCommandTarget;
|
||||
GUID fCommandCategory;
|
||||
HWND fToolbarWindow;
|
||||
|
|
|
@ -903,10 +903,21 @@ HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10,
|
|||
HRESULT hResult;
|
||||
|
||||
hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
|
||||
hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
|
||||
StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
|
||||
if (rgfInOut)
|
||||
{
|
||||
hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
}
|
||||
|
||||
ILFree(childPIDL);
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule,
|
|||
PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam;
|
||||
|
||||
if (IS_INTRESOURCE(lpszName))
|
||||
swprintf(szName, L"%u", lpszName);
|
||||
swprintf(szName, L"%u", (DWORD)lpszName);
|
||||
else
|
||||
wcscpy(szName, (WCHAR*)lpszName);
|
||||
|
||||
|
|
|
@ -753,11 +753,13 @@ EXTERN_C LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl)
|
|||
*/
|
||||
UINT WINAPI ILGetSize(LPCITEMIDLIST pidl)
|
||||
{
|
||||
LPCSHITEMID si = &(pidl->mkid);
|
||||
LPCSHITEMID si;
|
||||
UINT len = 0;
|
||||
|
||||
if (pidl)
|
||||
{
|
||||
si = &(pidl->mkid);
|
||||
|
||||
while (si->cb)
|
||||
{
|
||||
len += si->cb;
|
||||
|
|
|
@ -752,7 +752,7 @@ DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
|
|||
temppsfi.dwAttributes=psfi->dwAttributes;
|
||||
|
||||
if (psfi == NULL)
|
||||
ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, sizeof(temppsfi), flags);
|
||||
ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
|
||||
else
|
||||
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)
|
||||
{
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
LPITEMIDLIST pidlOut = NULL,
|
||||
pidlTemp = NULL;
|
||||
IShellFolder *psfChild;
|
||||
LPITEMIDLIST pidlIn = pidlInOut ? *pidlInOut : NULL;
|
||||
LPITEMIDLIST pidlOut = NULL;
|
||||
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 */
|
||||
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);
|
||||
psfChild->Release();
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
pidlTemp = ILCombine (*pidlInOut, pidlOut);
|
||||
|
||||
if (!pidlTemp)
|
||||
pidlTemp = ILCombine (pidlIn, pidlOut);
|
||||
if (!pidlTemp)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
if (pidlOut)
|
||||
ILFree(pidlOut);
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (pidlOut)
|
||||
ILFree (pidlOut);
|
||||
}
|
||||
|
||||
ILFree (*pidlInOut);
|
||||
if (pidlIn)
|
||||
ILFree (pidlIn);
|
||||
|
||||
*pidlInOut = pidlTemp;
|
||||
|
||||
TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
|
||||
return hr;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
Loading…
Reference in a new issue