mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 22:31:38 +00:00
[SHELL32]
- Disentangle icon extraction for control panel. Add CCPLExtractIcon_CreateInstance and isolate control panel handling in CControlPanelFolder.cpp. svn path=/trunk/; revision=71225
This commit is contained in:
parent
c368ace889
commit
535cdf4620
3 changed files with 30 additions and 32 deletions
|
@ -358,12 +358,7 @@ IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl)
|
|||
{
|
||||
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))
|
||||
|
|
|
@ -125,6 +125,31 @@ static PIDLCPanelStruct *_ILGetCPanelPointer(LPCITEMIDLIST pidl)
|
|||
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 @@ HRESULT WINAPI CControlPanelFolder::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",
|
||||
|
@ -482,16 +507,9 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
|
|||
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 @@ HRESULT WINAPI CControlPanelFolder::GetCurFolder(LPITEMIDLIST * pidl)
|
|||
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;
|
||||
|
|
|
@ -76,7 +76,6 @@ HRESULT WINAPI CShell_Constructor(REFIID riid, LPVOID * ppvOut);
|
|||
|
||||
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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue