Author: gadamopoulos
Date: Sat Apr 30 15:30:59 2016
New Revision: 71217
URL:
http://svn.reactos.org/svn/reactos?rev=71217&view=rev
Log:
[SHELL32]
- Get rid of CPrintersExtractIconW and add CPrintersExtractIconW_CreateInstane which
creates and initializes CExtractIcon.
- Also add CNetFolderExtractIcon_CreateInstance and CRecyclerExtractIcon_CreateInstance.
Modified:
trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp
Modified: trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp [iso-8859-1] Sat Apr 30
15:30:59 2016
@@ -47,6 +47,18 @@
* IShellFolder implementation
*/
+HRESULT CNetFolderExtractIcon_CreateInstance(LPCITEMIDLIST pidl, REFIID riid, LPVOID *
ppvOut)
+{
+ CComPtr<IDefaultExtractIconInit> initIcon;
+ HRESULT hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,
&initIcon));
+ if (FAILED(hr))
+ return NULL;
+
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_NETWORK_FOLDER);
+
+ return initIcon->QueryInterface(riid, ppvOut);
+}
+
class CNetFolderEnum :
public CEnumIDListBase
{
@@ -403,8 +415,7 @@
HRESULT WINAPI CNetFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY
apidl, REFIID riid,
UINT * prgfInOut, LPVOID * ppvOut)
{
- LPITEMIDLIST pidl;
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", this,
@@ -427,19 +438,9 @@
hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, &pDo);
pObj = pDo;
}
- else if (IsEqualIID(riid, IID_IExtractIconA) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconA_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
- }
- else if (IsEqualIID(riid, IID_IExtractIconW) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconW_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
+ else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW))
&& (cidl == 1))
+ {
+ hr = CNetFolderExtractIcon_CreateInstance(apidl[0], riid, &pObj);
}
else if (IsEqualIID(riid, IID_IDropTarget) && (cidl >= 1))
{
Modified: trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp [iso-8859-1] Sat Apr 30
15:30:59 2016
@@ -26,35 +26,6 @@
#include <winspool.h>
WINE_DEFAULT_DEBUG_CHANNEL (shell);
-
-/***********************************************************************
- * Printers_IExtractIconW implementation
- */
-class CPrintersExtractIconW :
- public CComObjectRootEx<CComMultiThreadModelNoCS>,
- public IExtractIconW,
- public IExtractIconA
-{
- private:
- LPITEMIDLIST pidl;
- public:
- CPrintersExtractIconW();
- ~CPrintersExtractIconW();
- HRESULT WINAPI Initialize(LPCITEMIDLIST pidl);
-
- // IExtractIconW
- virtual HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, LPWSTR szIconFile,
UINT cchMax, int *piIndex, UINT *pwFlags);
- virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT nIconIndex, HICON
*phiconLarge, HICON *phiconSmall, UINT nIconSize);
-
- // IExtractIconA
- virtual HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, LPSTR szIconFile,
UINT cchMax, int *piIndex, UINT *pwFlags);
- virtual HRESULT STDMETHODCALLTYPE Extract(LPCSTR pszFile, UINT nIconIndex, HICON
*phiconLarge, HICON *phiconSmall, UINT nIconSize);
-
- BEGIN_COM_MAP(CPrintersExtractIconW)
- COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW)
- COM_INTERFACE_ENTRY_IID(IID_IExtractIconA, IExtractIconA)
- END_COM_MAP()
-};
static shvheader PrinterSFHeader[] = {
{IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 15},
@@ -72,123 +43,24 @@
#define COLUMN_LOCATION 4
#define COLUMN_MODEL 5
-
#define PrinterSHELLVIEWCOLUMNS (6)
-CPrintersExtractIconW::CPrintersExtractIconW()
-{
- pidl = NULL;
-}
-
-CPrintersExtractIconW::~CPrintersExtractIconW()
-{
- TRACE(" destroying IExtractIcon(%p)\n", this);
- SHFree(pidl);
-}
-
-HRESULT WINAPI CPrintersExtractIconW::Initialize(LPCITEMIDLIST pidl)
-{
- pidl = ILClone(pidl);
-
- pdump(pidl);
- return S_OK;
-}
-
-/**************************************************************************
- * CPrintersExtractIconW::GetIconLocation
- *
- * mapping filetype to icon
- */
-HRESULT WINAPI CPrintersExtractIconW::GetIconLocation(UINT uFlags, /* GIL_ flags
*/
- LPWSTR szIconFile,
- UINT cchMax,
- int *piIndex,
- UINT *pwFlags) /* returned GIL_ flags */
-{
- TRACE("(%p) (flags=%u %p %u %p %p)\n", this, uFlags, szIconFile, cchMax,
piIndex, pwFlags);
-
- if (pwFlags)
- *pwFlags = 0;
-
- lstrcpynW(szIconFile, swShell32Name, cchMax);
- *piIndex = -IDI_SHELL_PRINTERS_FOLDER; /* FIXME: other icons for default, network,
print to file */
-
- TRACE("-- %s %x\n", debugstr_w(szIconFile), *piIndex);
- return S_OK;
-}
-
-/**************************************************************************
- * CPrintersExtractIconW::Extract
- */
-HRESULT WINAPI CPrintersExtractIconW::Extract(LPCWSTR pszFile,
- UINT nIconIndex, HICON *phiconLarge,
- HICON *phiconSmall, UINT nIconSize)
-{
- int index;
- HIMAGELIST big_icons, small_icons;
-
- FIXME("(%p) (file=%p index=%d %p %p size=%x) semi-stub\n", this,
debugstr_w(pszFile),
- (signed)nIconIndex, phiconLarge, phiconSmall, nIconSize);
-
- index = SIC_GetIconIndex(pszFile, nIconIndex, 0);
-
- Shell_GetImageLists(&big_icons, &small_icons);
-
- if (phiconLarge)
- *phiconLarge = ImageList_GetIcon(big_icons, index, ILD_TRANSPARENT);
-
- if (phiconSmall)
- *phiconSmall = ImageList_GetIcon(small_icons, index, ILD_TRANSPARENT);
-
- return S_OK;
-}
-
-/**************************************************************************
- * CPrintersExtractIconW::GetIconLocation
- */
-HRESULT WINAPI CPrintersExtractIconW::GetIconLocation(UINT uFlags,
- LPSTR szIconFile,
- UINT cchMax,
- int * piIndex,
- UINT * pwFlags)
-{
- HRESULT ret;
- LPWSTR lpwstrFile = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR));
-
- TRACE("(%p) (flags=%u %p %u %p %p)\n", this, uFlags, szIconFile, cchMax,
piIndex, pwFlags);
-
- ret = GetIconLocation(uFlags, lpwstrFile, cchMax, piIndex, pwFlags);
- WideCharToMultiByte(CP_ACP, 0, lpwstrFile, -1, szIconFile, cchMax, NULL, NULL);
- HeapFree(GetProcessHeap(), 0, lpwstrFile);
-
- TRACE("-- %s %x\n", szIconFile, *piIndex);
- return ret;
-}
-/**************************************************************************
- * CPrintersExtractIconW::Extract
- */
-HRESULT WINAPI CPrintersExtractIconW::Extract(LPCSTR pszFile,
- UINT nIconIndex, HICON *phiconLarge,
- HICON *phiconSmall, UINT nIconSize)
-{
- HRESULT ret;
- INT len = MultiByteToWideChar(CP_ACP, 0, pszFile, -1, NULL, 0);
- LPWSTR lpwstrFile = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
-
- TRACE("(%p) (file=%p index=%u %p %p size=%u)\n", this, pszFile, nIconIndex,
phiconLarge, phiconSmall, nIconSize);
-
- MultiByteToWideChar(CP_ACP, 0, pszFile, -1, lpwstrFile, len);
- ret = Extract(lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
- HeapFree(GetProcessHeap(), 0, lpwstrFile);
- return ret;
-}
-
-/**************************************************************************
- * IExtractIcon_Constructor
- */
-static HRESULT WINAPI IEI_Printers_Constructor(LPCITEMIDLIST pidl, REFIID riid, IUnknown
**ppv)
-{
- return ShellObjectCreatorInit<CPrintersExtractIconW>(pidl, riid, ppv);
+/**************************************************************************
+ * CPrintersExtractIconW_CreateInstane
+ *
+ * There is no CPrintersExtractIconW. We just initialize CExtractIcon properly to do our
job.
+ */
+HRESULT WINAPI CPrintersExtractIconW_CreateInstane(LPCITEMIDLIST pidl, REFIID riid,
LPVOID *ppv)
+{
+ CComPtr<IDefaultExtractIconInit> initIcon;
+ HRESULT hr =
SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
+ if (FAILED(hr))
+ return NULL;
+
+ /* FIXME: other icons for default, network, print to file */
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_PRINTERS_FOLDER);
+
+ return initIcon->QueryInterface(riid,ppv);
}
/***********************************************************************
@@ -462,7 +334,7 @@
HRESULT WINAPI CPrinterFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
{
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
@@ -474,7 +346,7 @@
*ppvOut = NULL;
if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW))
&& cidl == 1)
- hr = IEI_Printers_Constructor(apidl[0], riid, &pObj);
+ hr = CPrintersExtractIconW_CreateInstane(apidl[0], riid, &pObj);
else
hr = E_NOINTERFACE;
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] Sat Apr 30
15:30:59 2016
@@ -62,6 +62,19 @@
/*
* Recycle Bin folder
*/
+
+HRESULT CRecyclerExtractIcon_CreateInstance(LPCITEMIDLIST pidl, REFIID riid, LPVOID *
ppvOut)
+{
+ CComPtr<IDefaultExtractIconInit> initIcon;
+ HRESULT hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,
&initIcon));
+ if (FAILED(hr))
+ return NULL;
+
+ /* FIXME: This is completely unimplemented */
+ initIcon->SetNormalIcon(swShell32Name, 0);
+
+ return initIcon->QueryInterface(riid, ppvOut);
+}
class CRecycleBinEnum :
public CEnumIDListBase
@@ -571,7 +584,7 @@
HRESULT WINAPI CRecycleBin::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
REFIID riid, UINT *prgfInOut, void **ppv)
{
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(%p,%u,apidl=%p, %p %p)\n", this,
@@ -592,21 +605,9 @@
hr = QueryInterface(IID_PPV_ARG(IDropTarget, &pDt));
pObj = pDt;
}
- else if(IsEqualIID(riid, IID_IExtractIconA) && (cidl == 1))
- {
- // FIXME: This is not correct, it does not show the right icons
- LPITEMIDLIST pidlItem = ILCombine(pidl, apidl[0]);
- pObj = IExtractIconA_Constructor(pidlItem);
- SHFree(pidlItem);
- hr = S_OK;
- }
- else if (IsEqualIID(riid, IID_IExtractIconW) && (cidl == 1))
- {
- // FIXME: This is not correct, it does not show the right icons
- LPITEMIDLIST pidlItem = ILCombine(pidl, apidl[0]);
- pObj = IExtractIconW_Constructor(pidlItem);
- SHFree(pidlItem);
- hr = S_OK;
+ else if((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW))
&& (cidl == 1))
+ {
+ hr = CRecyclerExtractIcon_CreateInstance(apidl[0], riid, &pObj);
}
else
hr = E_NOINTERFACE;
@@ -686,8 +687,10 @@
HRESULT WINAPI CRecycleBin::GetDefaultColumn(DWORD dwReserved, ULONG *pSort, ULONG
*pDisplay)
{
TRACE("(%p, %x, %p, %p)\n", this, (unsigned int)dwReserved, pSort,
pDisplay);
- *pSort = 0;
- *pDisplay = 0;
+ if (pSort)
+ *pSort = 0;
+ if (pDisplay)
+ *pDisplay = 0;
return S_OK;
}