Commit d0065323 authored by Juergen Schmied's avatar Juergen Schmied Committed by Alexandre Julliard

- reorganised icon extracing from files

- made extracting from ne and ico files working - IPersistFile interface for IExtractIcon
parent a9e93b35
......@@ -22,13 +22,17 @@
*/
typedef struct
{ ICOM_VTABLE(IExtractIconA)* lpvtbl;
DWORD ref;
LPITEMIDLIST pidl;
{ ICOM_VTABLE(IExtractIconA)* lpvtbl;
DWORD ref;
ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
LPITEMIDLIST pidl;
} IExtractIconAImpl;
static struct ICOM_VTABLE(IExtractIconA) eivt;
static struct ICOM_VTABLE(IPersistFile) pfvt;
#define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
#define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((void*)name)-_IPersistFile_Offset);
/**************************************************************************
* IExtractIconA_Constructor
......@@ -39,7 +43,8 @@ IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
ei->ref=1;
ei->lpvtbl=&eivt;
ei->lpvtbl = &eivt;
ei->lpvtblPersistFile = &pfvt;
ei->pidl=ILClone(pidl);
pdump(pidl);
......@@ -61,10 +66,13 @@ static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REF
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
{ *ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
{ *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
}
else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
{ *ppvObj = (IExtractIconA*)This;
}
......@@ -112,18 +120,81 @@ static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
/**************************************************************************
* IExtractIconA_GetIconLocation
*/
static HRESULT WINAPI IExtractIconA_fnGetIconLocation(IExtractIconA * iface, UINT uFlags, LPSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags)
static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
IExtractIconA * iface,
UINT uFlags,
LPSTR szIconFile,
UINT cchMax,
int * piIndex,
UINT * pwFlags)
{
ICOM_THIS(IExtractIconAImpl,iface);
WARN (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
char sTemp[MAX_PATH];
DWORD ret = S_FALSE, dwNr;
LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
TRACE (shell,"(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
*piIndex = (int) SHMapPIDLToSystemImageListIndex(0, This->pidl,0);
*pwFlags = GIL_NOTFILENAME;
if (pwFlags)
*pwFlags = 0;
WARN (shell,"-- %x\n",*piIndex);
if (_ILIsDesktop(pSimplePidl))
{ strncpy(szIconFile, "shell32.dll", cchMax);
*piIndex = 34;
ret = NOERROR;
}
else if (_ILIsMyComputer(pSimplePidl))
{ if (HCR_GetDefaultIcon("CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", sTemp, MAX_PATH, &dwNr))
{ strncpy(szIconFile, sTemp, cchMax);
*piIndex = dwNr;
}
else
{ strncpy(szIconFile, "shell32.dll", cchMax);
*piIndex = 15;
}
ret = NOERROR;
}
else if (_ILIsDrive (pSimplePidl))
{ if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
{ strncpy(szIconFile, sTemp, cchMax);
*piIndex = dwNr;
}
else
{ strncpy(szIconFile, "shell32.dll", cchMax);
*piIndex = 8;
}
ret = NOERROR;
}
else if (_ILIsFolder (pSimplePidl))
{ if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
{ strncpy(szIconFile, sTemp, cchMax);
*piIndex = dwNr;
}
else
{ strncpy(szIconFile, "shell32.dll", cchMax);
*piIndex = 3;
}
ret = NOERROR;
}
else
{ if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)) /* object is file */
{ if ( HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH))
{ if (HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
{ if (!strcmp("%1",sTemp)) /* icon is in the file */
{ _ILGetPidlPath(This->pidl, sTemp, MAX_PATH);
dwNr = 0;
}
strncpy(szIconFile, sTemp, cchMax);
*piIndex = dwNr;
ret = NOERROR;
}
}
}
}
return NOERROR;
TRACE (shell,"-- %s %x\n", debugstr_a(szIconFile), *piIndex);
return ret;
}
/**************************************************************************
* IExtractIconA_Extract
......@@ -132,10 +203,14 @@ static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszF
{
ICOM_THIS(IExtractIconAImpl,iface);
FIXME (shell,"(%p) (file=%s index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
FIXME (shell,"(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
if (phiconLarge)
*phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
if (phiconSmall)
*phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
*phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
*phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
return S_OK;
}
......@@ -146,3 +221,80 @@ static struct ICOM_VTABLE(IExtractIconA) eivt =
IExtractIconA_fnGetIconLocation,
IExtractIconA_fnExtract
};
/************************************************************************
* IEIPersistFile_QueryInterface (IUnknown)
*/
static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
IPersistFile *iface,
REFIID iid,
LPVOID *ppvObj)
{
_ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
}
/************************************************************************
* IEIPersistFile_AddRef (IUnknown)
*/
static ULONG WINAPI IEIPersistFile_fnAddRef(
IPersistFile *iface)
{
_ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
return IExtractIconA_AddRef((IExtractIconA*)This);
}
/************************************************************************
* IEIPersistFile_Release (IUnknown)
*/
static ULONG WINAPI IEIPersistFile_fnRelease(
IPersistFile *iface)
{
_ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
return IExtractIconA_Release((IExtractIconA*)This);
}
/************************************************************************
* IEIPersistFile_GetClassID (IPersist)
*/
static HRESULT WINAPI IEIPersistFile_fnGetClassID(
const IPersistFile *iface,
LPCLSID lpClassId)
{
CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
if (lpClassId==NULL)
return E_POINTER;
memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
return S_OK;
}
/************************************************************************
* IEIPersistFile_Load (IPersistFile)
*/
static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
{
_ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
FIXME(shell,"%p\n", This);
return E_NOTIMPL;
}
static struct ICOM_VTABLE(IPersistFile) pfvt =
{
IEIPersistFile_fnQueryInterface,
IEIPersistFile_fnAddRef,
IEIPersistFile_fnRelease,
IEIPersistFile_fnGetClassID,
(void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
IEIPersistFile_fnLoad,
(void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
(void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
(void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
};
......@@ -219,10 +219,14 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
}
if (flags & SHGFI_SYSICONINDEX)
{ if (!pPidlTemp)
{ IShellFolder * sf;
if (!pPidlTemp)
{ pPidlTemp = ILCreateFromPathA (szTemp);
}
psfi->iIcon = SHMapPIDLToSystemImageListIndex (NULL, pPidlTemp, 0);
if (SUCCEEDED (SHGetDesktopFolder (&sf)))
{ psfi->iIcon = SHMapPIDLToSystemImageListIndex (sf, pPidlTemp, 0);
IShellFolder_Release(sf);
}
TRACE(shell,"-- SYSICONINDEX %i\n", psfi->iIcon);
if (flags & SHGFI_SMALLICON)
......@@ -401,30 +405,30 @@ UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
LPSHELLFOLDER pdesktopfolder=NULL;
DWORD WINAPI SHGetDesktopFolder(LPSHELLFOLDER *shellfolder)
{ HRESULT hres = E_OUTOFMEMORY;
LPCLASSFACTORY lpclf;
{ HRESULT hres = E_OUTOFMEMORY;
LPCLASSFACTORY lpclf;
TRACE(shell,"%p->(%p)\n",shellfolder,*shellfolder);
if (pdesktopfolder) {
hres = NOERROR;
} else {
lpclf = IClassFactory_Constructor();
/* fixme: the buildin IClassFactory_Constructor is at the moment only
for rclsid=CLSID_ShellDesktop, so we get the right Interface (jsch)*/
if(lpclf) {
hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
IClassFactory_Release(lpclf);
if (pdesktopfolder)
{ hres = NOERROR;
}
else
{ lpclf = IClassFactory_Constructor();
if(lpclf)
{ hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
IClassFactory_Release(lpclf);
}
}
}
if (pdesktopfolder) {
*shellfolder = pdesktopfolder;
pdesktopfolder->lpvtbl->fnAddRef(pdesktopfolder);
} else {
*shellfolder=NULL;
if (pdesktopfolder)
{ *shellfolder = pdesktopfolder;
IShellFolder_AddRef(pdesktopfolder);
}
else
{ *shellfolder=NULL;
}
TRACE(shell,"-- %p->(%p)\n",shellfolder, *shellfolder);
TRACE(shell,"-- %p->(%p)\n",shellfolder, *shellfolder);
return hres;
}
......@@ -1044,6 +1048,7 @@ void (WINAPI* pDLLInitComctl)(LPVOID);
INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
......@@ -1056,6 +1061,7 @@ BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
BOOL (WINAPI* pDPA_Destroy) (const HDPA);
INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
/* user32 */
HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
......@@ -1078,7 +1084,7 @@ BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
TRACE(shell,"0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
shell32_hInstance = hinstDLL;
switch (fdwReason)
{ case DLL_PROCESS_ATTACH:
if (!bShell32IsInitialized)
......@@ -1094,6 +1100,7 @@ BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
/* imports by ordinal, pray that it works*/
pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
......@@ -1102,6 +1109,7 @@ BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
/* user32 */
......
......@@ -8,6 +8,7 @@
#include "imagelist.h"
#include "commctrl.h"
#include "shell.h"
#include "docobj.h"
#include "wine/obj_shellfolder.h"
#include "wine/obj_dataobject.h"
......@@ -31,6 +32,7 @@ extern void (WINAPI* pDLLInitComctl)(LPVOID);
extern INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
extern INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
extern HIMAGELIST (WINAPI* pImageList_Create) (INT,INT,UINT,INT,INT);
extern BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
extern HICON (WINAPI* pImageList_GetIcon) (HIMAGELIST, INT, UINT);
extern INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
......@@ -43,6 +45,8 @@ extern BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
extern LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
extern BOOL (WINAPI* pDPA_Destroy) (const HDPA);
extern INT (WINAPI* pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
extern LPVOID (WINAPI* pDPA_DeletePtr) (const HDPA hdpa, INT i);
#define pDPA_GetPtrCount(hdpa) (*(INT*)(hdpa))
extern HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
extern HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
......@@ -63,7 +67,7 @@ LPITEMIDLIST WINAPI ILCreateFromPathA(LPSTR path);
LPITEMIDLIST WINAPI ILCreateFromPathW(LPWSTR path);
LPITEMIDLIST WINAPI ILCreateFromPathAW(LPVOID path);
DWORD WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
HRESULT WINAPI StrRetToStrN (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl);
/* Iconcache */
......
......@@ -113,7 +113,7 @@ extern void IDLList_Destructor(LPIDLLIST me);
typedef GUID SHELLVIEWID;
#define SV_CLASS_NAME ("SHELLDLL_DefView")
DWORD WINAPI SHMapPIDLToSystemImageListIndex(LPSHELLFOLDER sh,LPITEMIDLIST pidl,DWORD z);
UINT WINAPI SHMapPIDLToSystemImageListIndex(LPSHELLFOLDER sh, LPITEMIDLIST pidl, UINT * pIndex);
/****************************************************************************
* IShellIcon interface
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment