Author: akhaldi
Date: Fri Dec 4 11:12:01 2015
New Revision: 70264
URL:
http://svn.reactos.org/svn/reactos?rev=70264&view=rev
Log:
[SHELL32] Disable 'Empty Recycle Bin' when no items are present. By Mark Jansen.
CORE-10438
Modified:
trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp
trunk/reactos/dll/win32/shell32/folders/CRecycleBin.h
Modified: trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp [iso-8859-1] Fri Dec 4
11:12:01 2015
@@ -801,6 +801,17 @@
return S_OK;
}
+BOOL CRecycleBin::RecycleBinIsEmpty()
+{
+ CComPtr<IEnumIDList> spEnumFiles;
+ HRESULT hr = EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
&spEnumFiles);
+ if (FAILED(hr))
+ return TRUE;
+ CComHeapPtr<ITEMIDLIST> spPidl;
+ ULONG itemcount;
+ return spEnumFiles->Next(1, &spPidl, &itemcount) != S_OK;
+ }
+
/*************************************************************************
* RecycleBin IContextMenu interface
*/
@@ -819,7 +830,7 @@
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
- mii.fState = MFS_ENABLED;
+ mii.fState = RecycleBinIsEmpty() ? MFS_DISABLED : MFS_ENABLED;
szBuffer[0] = L'\0';
LoadStringW(shell32_hInstance, IDS_EMPTY_BITBUCKET, szBuffer, sizeof(szBuffer) /
sizeof(WCHAR));
mii.dwTypeData = szBuffer;
Modified: trunk/reactos/dll/win32/shell32/folders/CRecycleBin.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CRecycleBin.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CRecycleBin.h [iso-8859-1] Fri Dec 4 11:12:01
2015
@@ -44,6 +44,7 @@
void SF_RegisterClipFmt();
BOOL fAcceptFmt; /* flag for pending Drop */
BOOL QueryDrop (DWORD dwKeyState, LPDWORD pdwEffect);
+ BOOL RecycleBinIsEmpty();
public:
CRecycleBin();