@@ -2595,49 +2595,41 @@ void CItemManager::IconInfo::SetPath( const wchar_t *path )
2595
2595
timestamp.dwHighDateTime =timestamp.dwLowDateTime =0 ;
2596
2596
}
2597
2597
2598
- void CItemManager::LoadCustomIcon ( const wchar_t *iconPath, int iconIndex, int refreshFlags, const IconInfo *&smallIcon, const IconInfo *&largeIcon, const IconInfo *&extraLargeIcon, bool bTemp )
2598
+ void CItemManager::LoadCustomIcon (const wchar_t *iconPath, int iconIndex, int refreshFlags, const IconInfo *&smallIcon, const IconInfo *&largeIcon, const IconInfo *&extraLargeIcon, bool bTemp)
2599
2599
{
2600
- unsigned int hash= CalcFNVHash (iconPath,CalcFNVHash (&iconIndex,4 ));
2600
+ unsigned int hash = CalcFNVHash (iconPath, CalcFNVHash (&iconIndex, 4 ));
2601
2601
2602
- FindInCache (hash,refreshFlags,smallIcon,largeIcon,extraLargeIcon);
2603
- if (!refreshFlags) return ;
2602
+ FindInCache (hash, refreshFlags, smallIcon, largeIcon, extraLargeIcon);
2603
+ if (!refreshFlags)
2604
+ return ;
2604
2605
2605
- // extract icon
2606
- HBITMAP hSmallBitmap=NULL , hLargeBitmap=NULL , hExtraLargeBitmap=NULL ;
2607
- if (refreshFlags&INFO_SMALL_ICON)
2608
- {
2606
+ auto ExtractIconAsBitmap = [&](int iconSize) -> HBITMAP {
2609
2607
HICON hIcon;
2610
- if (!*iconPath)
2611
- hIcon=(HICON)LoadImage (g_Instance,MAKEINTRESOURCE (-iconIndex),IMAGE_ICON,SMALL_ICON_SIZE,SMALL_ICON_SIZE,LR_DEFAULTCOLOR);
2612
- else
2613
- hIcon=ShExtractIcon (iconPath,iconIndex==-1 ?0 :iconIndex,SMALL_ICON_SIZE);
2614
- if (hIcon)
2615
- hSmallBitmap=BitmapFromIcon (hIcon,SMALL_ICON_SIZE);
2616
- }
2617
2608
2618
- if (refreshFlags&INFO_LARGE_ICON)
2619
- {
2620
- HICON hIcon;
2621
2609
if (!*iconPath)
2622
- hIcon= (HICON)LoadImage (g_Instance,MAKEINTRESOURCE (-iconIndex),IMAGE_ICON,LARGE_ICON_SIZE,LARGE_ICON_SIZE, LR_DEFAULTCOLOR);
2610
+ hIcon = (HICON)LoadImage (g_Instance, MAKEINTRESOURCE (-iconIndex), IMAGE_ICON, iconSize, iconSize, LR_DEFAULTCOLOR);
2623
2611
else
2624
- hIcon=ShExtractIcon (iconPath,iconIndex==-1 ?0 :iconIndex,LARGE_ICON_SIZE);
2625
- if (hIcon)
2626
- hLargeBitmap=BitmapFromIcon (hIcon,LARGE_ICON_SIZE);
2627
- }
2612
+ hIcon = ShExtractIcon (iconPath, iconIndex == -1 ? 0 : iconIndex, iconSize);
2628
2613
2629
- if (refreshFlags&INFO_EXTRA_LARGE_ICON)
2630
- {
2631
- HICON hIcon;
2632
- if (!*iconPath)
2633
- hIcon=(HICON)LoadImage (g_Instance,MAKEINTRESOURCE (-iconIndex),IMAGE_ICON,EXTRA_LARGE_ICON_SIZE,EXTRA_LARGE_ICON_SIZE,LR_DEFAULTCOLOR);
2634
- else
2635
- hIcon=ShExtractIcon (iconPath,iconIndex==-1 ?0 :iconIndex,EXTRA_LARGE_ICON_SIZE);
2636
2614
if (hIcon)
2637
- hExtraLargeBitmap=BitmapFromIcon (hIcon,EXTRA_LARGE_ICON_SIZE);
2638
- }
2615
+ return BitmapFromIcon (hIcon, iconSize);
2616
+
2617
+ return nullptr ;
2618
+ };
2619
+
2620
+ // extract icon
2621
+ HBITMAP hSmallBitmap = nullptr , hLargeBitmap = nullptr , hExtraLargeBitmap = nullptr ;
2622
+
2623
+ if (refreshFlags & INFO_SMALL_ICON)
2624
+ hSmallBitmap = ExtractIconAsBitmap (SMALL_ICON_SIZE);
2625
+
2626
+ if (refreshFlags & INFO_LARGE_ICON)
2627
+ hLargeBitmap = ExtractIconAsBitmap (LARGE_ICON_SIZE);
2628
+
2629
+ if (refreshFlags & INFO_EXTRA_LARGE_ICON)
2630
+ hExtraLargeBitmap = ExtractIconAsBitmap (EXTRA_LARGE_ICON_SIZE);
2639
2631
2640
- StoreInCache (hash,bTemp? NULL : iconPath,hSmallBitmap,hLargeBitmap,hExtraLargeBitmap,refreshFlags,smallIcon,largeIcon,extraLargeIcon,bTemp,false );
2632
+ StoreInCache (hash, bTemp ? nullptr : iconPath, hSmallBitmap, hLargeBitmap, hExtraLargeBitmap, refreshFlags, smallIcon, largeIcon, extraLargeIcon, bTemp, false );
2641
2633
}
2642
2634
2643
2635
// Recursive function to preload the items for a folder
0 commit comments