Author: gadamopoulos
Date: Sun May  1 19:05:32 2016
New Revision: 71225

URL: http://svn.reactos.org/svn/reactos?rev=71225&view=rev
Log:
[SHELL32]
- Disentangle icon extraction for control panel. Add 
CCPLExtractIcon_CreateInstance and isolate control panel handling in 
CControlPanelFolder.cpp.

Modified:
    trunk/reactos/dll/win32/shell32/folders.cpp
    trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp
    trunk/reactos/dll/win32/shell32/wine/shell32_main.h

Modified: trunk/reactos/dll/win32/shell32/folders.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders.cpp?rev=71225&r1=71224&r2=71225&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] Sun May  1 
19:05:32 2016
@@ -358,12 +358,7 @@
     {
         BOOL found = FALSE;
 
-        if (_ILIsCPanelStruct(pSimplePidl))
-        {
-            if (SUCCEEDED(CPanel_GetIconLocationW(pSimplePidl, wTemp, 
MAX_PATH, &icon_idx)))
-                found = TRUE;
-        }
-        else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
+        if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
         {
             if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE)
                     && HCR_GetIconA(sTemp, sTemp, NULL, MAX_PATH, &icon_idx))

Modified: trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp?rev=71225&r1=71224&r2=71225&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp     
[iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp     
[iso-8859-1] Sun May  1 19:05:32 2016
@@ -125,6 +125,31 @@
     return NULL;
 }
 
+HRESULT CCPLExtractIcon_CreateInstance(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST 
pidl, REFIID riid, LPVOID * ppvOut)
+{
+    PIDLCPanelStruct *pData = _ILGetCPanelPointer(pidl);
+    if (!pData)
+    {
+        LPITEMIDLIST pidlComplete = ILCombine(pidlRoot, pidl);
+        if (!pidlComplete)
+            return E_OUTOFMEMORY;
+
+        *ppvOut = IExtractIconW_Constructor(pidlComplete);
+
+        SHFree(pidlComplete);
+        return *ppvOut ? S_OK : E_FAIL;
+    }
+
+    CComPtr<IDefaultExtractIconInit> initIcon;
+    HRESULT hr = 
SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit, &initIcon));
+    if (FAILED(hr))
+        return NULL;
+
+    initIcon->SetNormalIcon(pData->szName, (int)pData->iconIdx != -1 ? 
pData->iconIdx : 0);
+
+    return initIcon->QueryInterface(riid, ppvOut);
+}
+
 BOOL CControlPanelEnum::RegisterCPanelApp(LPCWSTR wpath)
 {
     CPlApplet* applet = Control_LoadApplet(0, wpath, NULL);
@@ -455,7 +480,7 @@
         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",
@@ -482,16 +507,9 @@
                 hr = CDefFolderMenu_Create2(pidlRoot, hwndOwner, cidl, apidl, 
(IShellFolder*)this, NULL, 0, NULL, (IContextMenu**)&pObj);
         } else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1)) {
             hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, 
(IDataObject **)&pObj);
-        } 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 = CCPLExtractIcon_CreateInstance(pidlRoot, apidl[0], riid, 
&pObj);
+
         } else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, 
IID_IShellLinkA))
                    && (cidl == 1)) {
             pidl = ILCombine(pidlRoot, apidl[0]);
@@ -669,20 +687,6 @@
     return S_OK;
 }
 
-HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST pidl, LPWSTR szIconFile, UINT 
cchMax, int* piIndex)
-{
-    PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
-
-    if (!pcpanel)
-        return E_INVALIDARG;
-
-    wcsncpy(szIconFile, pcpanel->szName, cchMax);
-    *piIndex = (int)pcpanel->iconIdx != -1 ? pcpanel->iconIdx : 0;
-
-    return S_OK;
-}
-
-
 CCPLItemMenu::CCPLItemMenu()
 {
     m_apidl = NULL;

Modified: trunk/reactos/dll/win32/shell32/wine/shell32_main.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/shell32_main.h?rev=71225&r1=71224&r2=71225&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] Sun May  1 
19:05:32 2016
@@ -76,7 +76,6 @@
 
 HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown * pUnkOuter, REFIID riid, 
LPCITEMIDLIST pidl, LPVOID * ppv);
 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, 
LPBC *ppV);
-extern HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST, LPWSTR, UINT, int*) 
DECLSPEC_HIDDEN;
 HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT 
nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) 
DECLSPEC_HIDDEN;
 HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT 
nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) 
DECLSPEC_HIDDEN;
 


Reply via email to