Better icon-handeling.

And enumerate through ICON instead of GROUP_ICON
This commit is contained in:
Coenraad Stijne 2014-07-19 15:34:52 +02:00
parent 10204a4526
commit 60df499584

View File

@ -243,31 +243,32 @@ namespace Wox.Plugin.SystemPlugins.ControlPanel
iconIndex = (IntPtr)sanitizeUint(iconString[1]); iconIndex = (IntPtr)sanitizeUint(iconString[1]);
if (iconIndex == IntPtr.Zero) iconPtr = LoadImage(dataFilePointer, iconIndex, 1, iconSize, iconSize, 0);
if (iconPtr == IntPtr.Zero)
{ {
iconQueue = new Queue<IntPtr>(); iconQueue = new Queue<IntPtr>();
EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, new EnumResNameDelegate(EnumRes), IntPtr.Zero); //Iterate through resources. EnumResourceNamesWithID(dataFilePointer, 3, new EnumResNameDelegate(EnumRes), IntPtr.Zero); //Iterate through resources.
while (iconPtr == IntPtr.Zero && iconQueue.Count > 0) while (iconPtr == IntPtr.Zero && iconQueue.Count > 0)
{ {
iconPtr = LoadImage(dataFilePointer, iconQueue.Dequeue(), 1, iconSize, iconSize, 0); iconPtr = LoadImage(dataFilePointer, iconQueue.Dequeue(), 1, iconSize, iconSize, 0);
} }
} }
else
{
iconPtr = LoadImage(dataFilePointer, iconIndex, 1, iconSize, iconSize, 0);
}
FreeLibrary(dataFilePointer); FreeLibrary(dataFilePointer);
try if (iconPtr != IntPtr.Zero)
{ {
myIcon = Icon.FromHandle(iconPtr); try
myIcon = (Icon)myIcon.Clone(); //Remove pointer dependancy. {
} myIcon = Icon.FromHandle(iconPtr);
catch myIcon = (Icon)myIcon.Clone(); //Remove pointer dependancy.
{ }
//Silently fail for now.. catch
{
//Silently fail for now.
}
} }
} }
} }