From 861282bf2815a70cff7ff16e9dbdd03021f858ef Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Mon, 11 Apr 2005 13:04:41 +0000 Subject: [PATCH] Fix the icon resource ids (most were off by one). Fix IExtractIcon_{GetIconLocation,Extract} to use -ve icon resource ids and fix bugs relating to confusion between resource ids and the system imagelist indicies. Extend the system imagelist initialization hack to load both +ve and -ve resource ids. Add a printer icon (that'll be used by an upcoming printer folder patch). --- dlls/shell32/.cvsignore | 1 + dlls/shell32/Makefile.in | 1 + dlls/shell32/classes.c | 7 ++- dlls/shell32/folders.c | 35 ++++++++------ dlls/shell32/iconcache.c | 3 +- dlls/shell32/shell32_main.c | 3 +- dlls/shell32/shres.rc | 96 ++++++++++++++++++++++++++++++++----- dlls/shell32/shresdef.h | 13 +++++ 8 files changed, 128 insertions(+), 31 deletions(-) diff --git a/dlls/shell32/.cvsignore b/dlls/shell32/.cvsignore index 47590bfce5a..c78c4e2c19a 100644 --- a/dlls/shell32/.cvsignore +++ b/dlls/shell32/.cvsignore @@ -10,6 +10,7 @@ folder_open.ico mycomputer.ico netdrive.ico netdrive2.ico +printer.ico ramdisk.ico shell.spec.c shell32.dll.dbg.c diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in index 987963bd798..1c024e7eb8c 100644 --- a/dlls/shell32/Makefile.in +++ b/dlls/shell32/Makefile.in @@ -62,6 +62,7 @@ RC_BINARIES = \ mycomputer.ico \ netdrive.ico \ netdrive2.ico \ + printer.ico \ ramdisk.ico C_SRCS16 = shell.c diff --git a/dlls/shell32/classes.c b/dlls/shell32/classes.c index f5e8c382951..96635f9765b 100644 --- a/dlls/shell32/classes.c +++ b/dlls/shell32/classes.c @@ -223,7 +223,12 @@ BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr ret = HCR_RegGetDefaultIconW(hkey, szDest, len, dwNr); RegCloseKey(hkey); } - TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr ); + + if(ret) + TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr ); + else + TRACE("-- not found\n"); + return ret; } diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c index 3f1b4694bb2..2977d3ec2b6 100644 --- a/dlls/shell32/folders.c +++ b/dlls/shell32/folders.c @@ -40,6 +40,7 @@ #include "pidl.h" #include "shell32_main.h" #include "shfldr.h" +#include "shresdef.h" WINE_DEFAULT_DEBUG_CHANNEL(shell); @@ -196,9 +197,9 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags, if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &dwNr)) { lstrcpynW(szIconFile, swShell32Name, cchMax); - dwNr = 3; + dwNr = IDI_SHELL_FOLDER; } - *piIndex = (uFlags & GIL_OPENICON) ? dwNr + 1 : dwNr; + *piIndex = -((uFlags & GIL_OPENICON) ? dwNr + 1 : dwNr); } return S_OK; } @@ -233,7 +234,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( if (_ILIsDesktop(pSimplePidl)) { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = 34; + *piIndex = -IDI_SHELL_DESKTOP; } /* my computer and other shell extensions */ @@ -257,7 +258,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( else { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = 15; + *piIndex = -IDI_SHELL_MYCOMPUTER; } } @@ -271,17 +272,17 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( { switch(GetDriveTypeA(sTemp)) { - case DRIVE_REMOVABLE: icon_idx = 5; break; - case DRIVE_CDROM: icon_idx = 11; break; - case DRIVE_REMOTE: icon_idx = 9; break; - case DRIVE_RAMDISK: icon_idx = 12; break; + case DRIVE_REMOVABLE: icon_idx = IDI_SHELL_FLOPPY; break; + case DRIVE_CDROM: icon_idx = IDI_SHELL_CDROM; break; + case DRIVE_REMOTE: icon_idx = IDI_SHELL_NETDRIVE; break; + case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break; } } if (icon_idx != -1) { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = icon_idx; + *piIndex = -icon_idx; } else { @@ -292,14 +293,14 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( else { lstrcpynW(szIconFile, swShell32Name, cchMax); - *piIndex = 8; + *piIndex = -IDI_SHELL_DRIVE; } } } else if (_ILIsFolder (pSimplePidl)) { - getIconLocationForFolder(iface, uFlags, szIconFile, cchMax, piIndex, - pwFlags); + getIconLocationForFolder(iface, uFlags, szIconFile, cchMax, piIndex, + pwFlags); } else { @@ -370,14 +371,18 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( static HRESULT WINAPI IExtractIconW_fnExtract(IExtractIconW * iface, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) { IExtractIconWImpl *This = (IExtractIconWImpl *)iface; + int index; - FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, debugstr_w(pszFile), nIconIndex, phiconLarge, phiconSmall, nIconSize); + FIXME("(%p) (file=%p index=%d %p %p size=%08x) semi-stub\n", This, debugstr_w(pszFile), (signed)nIconIndex, + phiconLarge, phiconSmall, nIconSize); + + index = SIC_GetIconIndex(pszFile, nIconIndex); if (phiconLarge) - *phiconLarge = ImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT); + *phiconLarge = ImageList_GetIcon(ShellBigIconList, index, ILD_TRANSPARENT); if (phiconSmall) - *phiconSmall = ImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT); + *phiconSmall = ImageList_GetIcon(ShellSmallIconList, index, ILD_TRANSPARENT); return S_OK; } diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index af4b2f519a9..9aa7742bc17 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -243,7 +243,8 @@ BOOL SIC_Initialize(void) hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_small, cy_small, LR_SHARED); hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_large, cy_large, LR_SHARED); } - SIC_IconAppend (swShell32Name, index, hSm, hLg); + SIC_IconAppend (swShell32Name, index - 1, hSm, hLg); + SIC_IconAppend (swShell32Name, -index, hSm, hLg); } TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList); diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c index 4a85a99cbb1..37c45ca21d1 100644 --- a/dlls/shell32/shell32_main.c +++ b/dlls/shell32/shell32_main.c @@ -44,6 +44,7 @@ #include "pidl.h" #include "shell32_main.h" #include "version.h" +#include "shresdef.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -501,7 +502,7 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, lstrcpynW(sTemp, szFullPath, MAX_PATH); if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - psfi->iIcon = 2; + psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER); else { static const WCHAR p1W[] = {'%','1',0}; diff --git a/dlls/shell32/shres.rc b/dlls/shell32/shres.rc index ddc12417d90..ac106ecc2d7 100644 --- a/dlls/shell32/shres.rc +++ b/dlls/shell32/shres.rc @@ -36,7 +36,7 @@ BEGIN END /* BINRES document.ico */ -1 ICON document.ico +IDI_SHELL_DOCUMENT ICON document.ico /* { '00 00 01 00 04 00 10 10 10 00 01 00 04 00 28 01' '00 00 46 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -340,7 +340,7 @@ END /* BINRES folder.ico */ -3 ICON folder.ico +IDI_SHELL_FOLDER ICON folder.ico /* { '00 00 01 00 04 00 10 10 10 00 01 00 04 00 28 01' '00 00 46 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -640,7 +640,7 @@ END } */ /* BINRES folder_open.ico */ -4 ICON folder_open.ico +IDI_SHELL_FOLDER_OPEN ICON folder_open.ico /* { '00 00 01 00 01 00 10 10 10 00 00 00 00 00 68 05' '00 00 16 00 00 00 28 00 00 00 10 00 00 00 20 00' @@ -733,7 +733,7 @@ END } */ /* BINRES floppy.ico */ -5 ICON floppy.ico +IDI_SHELL_FLOPPY ICON floppy.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -2315,7 +2315,7 @@ END /* BINRES drive.ico */ -8 ICON drive.ico +IDI_SHELL_DRIVE ICON drive.ico /* { '00 00 01 00 08 00 20 20 00 00 01 00 08 00 A8 08' '00 00 86 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -3793,7 +3793,7 @@ END } */ /* BINRES netdrive.ico */ -9 ICON netdrive.ico +IDI_SHELL_NETDRIVE ICON netdrive.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -5374,7 +5374,7 @@ END } */ /* BINRES netdrive2.ico */ -10 ICON netdrive2.ico +IDI_SHELL_NETDRIVE2 ICON netdrive2.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -6955,7 +6955,7 @@ END } */ /* BINRES cdrom.ico */ -11 ICON cdrom.ico +IDI_SHELL_CDROM ICON cdrom.ico /* { '00 00 01 00 09 00 20 20 00 00 01 00 08 00 A8 08' '00 00 96 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -8536,7 +8536,7 @@ END } */ /* BINRES ramdisk.ico */ -12 ICON ramdisk.ico +IDI_SHELL_RAMDISK ICON ramdisk.ico /* { '00 00 01 00 07 00 20 20 00 00 01 00 04 00 E8 02' '00 00 76 00 00 00 10 10 00 00 01 00 08 00 68 05' @@ -9908,7 +9908,7 @@ END /* BINRES mycomputer.ico */ -15 ICON mycomputer.ico +IDI_SHELL_MYCOMPUTER ICON mycomputer.ico /* { '00 00 01 00 02 00 10 10 10 00 01 00 04 00 28 01' '00 00 26 00 00 00 20 20 10 00 01 00 04 00 E8 02' @@ -9980,11 +9980,81 @@ END 'FF FF FF FF FF FF' } */ - - +/* BINRES printer.ico */ +IDI_SHELL_PRINTER ICON printer.ico +/* { + '00 00 01 00 02 00 20 20 10 00 00 00 00 00 E8 02' + '00 00 26 00 00 00 10 10 10 00 00 00 00 00 28 01' + '00 00 0E 03 00 00 28 00 00 00 20 00 00 00 40 00' + '00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00' + '00 00 80 00 80 00 80 80 00 00 C0 C0 C0 00 80 80' + '80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00' + '00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '08 88 88 88 88 8A A8 89 98 80 00 00 00 00 00 00' + '08 88 88 88 88 8A A8 89 98 80 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '08 88 88 88 88 88 88 88 88 80 00 00 00 00 00 00' + '00 77 77 77 77 77 77 77 77 77 00 00 00 00 00 00' + '00 07 77 77 77 77 77 77 77 77 70 00 00 00 00 00' + '00 00 77 77 77 77 77 77 77 77 77 00 00 00 00 00' + '00 00 07 7F FF FF FF FF FF FF FF 70 00 00 00 00' + '00 00 00 7F FF FF FF FF FF FF FF 77 00 00 00 00' + '00 00 00 0F FF FF FF FF FF FF FF 77 70 00 00 00' + '00 00 00 0F FF 00 00 00 00 0F FF 00 00 00 00 00' + '00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00 00' + '00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00 00' + '00 00 00 00 FF F0 00 00 00 00 FF F0 00 00 00 00' + '00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00 00' + '00 00 00 00 0F FF FF FF FF FF FF FF 00 00 00 00' + '00 00 00 00 0F FF 00 00 00 00 0F FF 00 00 00 00' + '00 00 00 00 0F FF FF FF FF FF FF FF 00 00 00 00' + '00 00 00 00 0F FF FF FF FF FF FF FF 00 00 00 00' + '00 00 00 00 00 FF F0 00 00 00 00 FF F0 00 00 00' + '00 00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00' + '00 00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00' + '00 00 00 00 00 FF FF FF FF FF FF FF F0 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF' + 'FF FF FF FF FF FF FF FF FF FF F8 00 00 FF F8 00' + '00 7F F8 00 00 3F F8 00 00 1F F8 00 00 0F F8 00' + '00 07 FC 00 00 07 FE 00 00 07 FF 00 00 07 FF 80' + '00 07 FF C0 00 07 FF E0 00 07 FF E0 00 3F FF F0' + '00 1F FF F0 00 1F FF F0 00 1F FF F0 00 1F FF F8' + '00 0F FF F8 00 0F FF F8 00 0F FF F8 00 0F FF FC' + '00 07 FF FC 00 07 FF FC 00 07 FF FC 00 07 FF FF' + 'FF FF FF FF FF FF FF FF FF FF FF FF FF FF 28 00' + '00 00 10 00 00 00 20 00 00 00 01 00 04 00 00 00' + '00 00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80' + '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' + '00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF' + '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' + '00 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 88 88 88 88 88 00 00 00 88' + '88 AA 89 98 00 00 00 88 88 88 88 88 00 00 00 77' + '77 77 77 77 70 00 00 07 7F FF FF FF 77 00 00 00' + '7F FF FF FF 77 70 00 00 0F 00 00 0F 00 00 00 00' + '0F FF FF FF F0 00 00 00 00 F0 00 00 F0 00 00 00' + '00 FF FF FF FF 00 00 00 00 0F 00 00 0F 00 00 00' + '00 0F FF FF FF 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 FF FF 00 00 FF FF 00 00 C0 07' + '00 00 C0 03 00 00 C0 01 00 00 C0 01 00 00 E0 01' + '00 00 F0 01 00 00 F8 0F 00 00 F8 07 00 00 FC 07' + '00 00 FC 03 00 00 FE 03 00 00 FE 03 00 00 FF FF' + '00 00 FF FF 00 00' +} */ /* BINRES desktop.ico */ -34 ICON desktop.ico +IDI_SHELL_DESKTOP ICON desktop.ico /* { '00 00 01 00 02 00 10 10 10 00 00 00 00 00 28 01' '00 00 26 00 00 00 20 20 10 00 00 00 00 00 E8 02' diff --git a/dlls/shell32/shresdef.h b/dlls/shell32/shresdef.h index d7419cc70f7..850041b5980 100644 --- a/dlls/shell32/shresdef.h +++ b/dlls/shell32/shresdef.h @@ -89,4 +89,17 @@ #define IDD_TITLE 0x3742 #define IDD_TREEVIEW 0x3741 +#define IDI_SHELL_DOCUMENT 1 +#define IDI_SHELL_FOLDER 4 +#define IDI_SHELL_FOLDER_OPEN 5 +#define IDI_SHELL_FLOPPY 6 +#define IDI_SHELL_DRIVE 9 +#define IDI_SHELL_NETDRIVE 10 +#define IDI_SHELL_NETDRIVE2 11 +#define IDI_SHELL_CDROM 12 +#define IDI_SHELL_RAMDISK 13 +#define IDI_SHELL_MYCOMPUTER 16 +#define IDI_SHELL_PRINTER 17 +#define IDI_SHELL_DESKTOP 35 + #endif