Initialize icon using InitFromHICON() instead of CreateFromHICON()

The former avoids an unnecessary call to ::GetIconInfo() done by the
latter to retrieve the icon size, as we already have the size here.
This commit is contained in:
Vadim Zeitlin
2018-11-18 23:09:01 +01:00
parent 262124ca1b
commit 8e740c69cd

View File

@@ -93,8 +93,13 @@ MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size)
if ( SHDefExtractIcon(path, index, 0, &hIcon, NULL, size.x) != S_OK )
return wxNullBitmap;
// Note that using "size.x" twice here is not a typo: normally size.y is
// the same anyhow, of course, but if it isn't, the actual icon size would
// be size.x in both directions as we only pass "x" to SHDefExtractIcon()
// above.
wxIcon icon;
icon.CreateFromHICON((WXHICON)hIcon);
if ( !icon.InitFromHICON((WXHICON)hIcon, size.x, size.x) )
return wxNullBitmap;
wxBitmap bitmap(icon);
::DestroyIcon(hIcon);