SHGetFileInfo fix
Aric Stewart
aric at codeweavers.com
Mon Oct 22 11:59:50 CDT 2001
This fixes the behavior for SHGetFileInfo when the
SHGFI_USEFILEATTRIBUTES flag is set. It corrects the given type and
icon.
-aric
-------------- next part --------------
Index: dlls/shell32/classes.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/classes.c,v
retrieving revision 1.18
diff -u -u -r1.18 classes.c
--- dlls/shell32/classes.c 2000/09/26 00:00:57 1.18
+++ dlls/shell32/classes.c 2001/10/22 15:25:49
@@ -27,6 +27,10 @@
TRACE("%s %p\n",szExtension, szFileType );
+ /* added becasue we do not want to have double dots */
+ if (szExtension[0]=='.')
+ bPrependDot=0;
+
if (bPrependDot)
strcpy(szTemp, ".");
Index: dlls/shell32/shell32_main.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.c,v
retrieving revision 1.86
diff -u -u -r1.86 shell32_main.c
--- dlls/shell32/shell32_main.c 2001/10/10 20:25:59 1.86
+++ dlls/shell32/shell32_main.c 2001/10/22 15:25:50
@@ -201,6 +201,7 @@
IExtractIconA * pei = NULL;
LPITEMIDLIST pidlLast = NULL, pidl = NULL;
HRESULT hr = S_OK;
+ BOOL IconNotYetLoaded=TRUE;
TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
(flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
@@ -323,7 +324,19 @@
/* get the type name */
if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
{
- _ILGetFileType(pidlLast, psfi->szTypeName, 80);
+ if (!flags & SHGFI_USEFILEATTRIBUTES)
+ _ILGetFileType(pidlLast, psfi->szTypeName, 80);
+ else
+ {
+ char sTemp[64];
+ strcpy(sTemp,PathFindExtensionA(path));
+ if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
+ && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
+ {
+ lstrcpynA (psfi->szTypeName, sTemp, 80 - 6);
+ strcat (psfi->szTypeName, "-file");
+ }
+ }
}
/* ### icons ###*/
@@ -359,6 +372,7 @@
/* get icon index (or load icon)*/
if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
{
+
if (flags & SHGFI_USEFILEATTRIBUTES)
{
char sTemp [MAX_PATH];
@@ -374,10 +388,16 @@
{
strcpy(sTemp, path);
}
- /* FIXME: if sTemp contains a valid filename, get the icon
- from there, index is in dwNr
- */
- psfi->iIcon = 2;
+ IconNotYetLoaded=FALSE;
+ psfi->iIcon = 0;
+ if (SHGFI_LARGEICON)
+ PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON),
+ &psfi->hIcon,0,1,0);
+ else
+ PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ &psfi->hIcon,0,1,0);
}
else /* default icon */
{
@@ -399,7 +419,7 @@
}
/* icon handle */
- if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
+ if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
More information about the wine-patches
mailing list