[PATCH 2/3] shell32: Use the imagelist to determine the icon size.

Huw Davies huw at codeweavers.com
Wed Apr 19 07:13:40 CDT 2017


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/shell32/iconcache.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c
index 7beb47967d..737f4d5023 100644
--- a/dlls/shell32/iconcache.c
+++ b/dlls/shell32/iconcache.c
@@ -298,6 +298,17 @@ static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallI
 	LeaveCriticalSection(&SHELL32_SicCS);
 	return ret;
 }
+
+static BOOL get_imagelist_icon_size(int list, SIZE *size)
+{
+    HIMAGELIST image_list;
+
+    if (list < SHIL_LARGE || list > SHIL_SMALL) return FALSE;
+    image_list = (list == SHIL_LARGE) ? ShellBigIconList : ShellSmallIconList;
+
+    return ImageList_GetIconSize( image_list, &size->cx, &size->cy );
+}
+
 /****************************************************************************
  * SIC_LoadIcon				[internal]
  *
@@ -311,11 +322,12 @@ static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
 	HICON 	hiconLargeShortcut;
 	HICON	hiconSmallShortcut;
         int ret;
+        SIZE size;
 
-        PrivateExtractIconsW( sSourceFile, dwSourceIndex, GetSystemMetrics(SM_CXICON),
-                              GetSystemMetrics(SM_CYICON), &hiconLarge, 0, 1, 0 );
-        PrivateExtractIconsW( sSourceFile, dwSourceIndex, GetSystemMetrics(SM_CXSMICON),
-                              GetSystemMetrics(SM_CYSMICON), &hiconSmall, 0, 1, 0 );
+        get_imagelist_icon_size( SHIL_LARGE, &size );
+        PrivateExtractIconsW( sSourceFile, dwSourceIndex, size.cx, size.cy, &hiconLarge, 0, 1, 0 );
+        get_imagelist_icon_size( SHIL_SMALL, &size );
+        PrivateExtractIconsW( sSourceFile, dwSourceIndex, size.cx, size.cy, &hiconSmall, 0, 1, 0 );
 
 	if ( !hiconLarge ||  !hiconSmall)
 	{
-- 
2.12.0




More information about the wine-patches mailing list