+ HICON hicon = NULL;
+
+ // Parse the filename: it may be of the form
+ // filename;n in order to specify the nth icon in the file.
+ // For the moment, ignore the issue of possible semicolons in the filename.
+ int iconIndex = 0;
+ wxString name1(name);
+ wxString strIconIndex = name.AfterLast(wxT(';'));
+ if (strIconIndex != name)
+ {
+ iconIndex = wxAtoi(strIconIndex);
+ name1 = name.BeforeLast(wxT(';'));
+ }
+
+ // were we asked for a large icon?
+ if ( desiredWidth == ::GetSystemMetrics(SM_CXICON) &&
+ desiredHeight == ::GetSystemMetrics(SM_CYICON) )
+ {
+ // get the specified large icon from file
+ if ( !::ExtractIconEx(name1, iconIndex, &hicon, NULL, 1) )
+ {
+ // it is not an error, but it might still be useful to be informed
+ // about it optionally
+ wxLogTrace(_T("iconload"),
+ _T("No large icons found in the file '%s'."),
+ name.c_str());
+ }
+ }
+ else if ( desiredWidth == ::GetSystemMetrics(SM_CXSMICON) &&
+ desiredHeight == ::GetSystemMetrics(SM_CYSMICON) )
+ {
+ // get the specified small icon from file
+ if ( !::ExtractIconEx(name1, iconIndex, NULL, &hicon, 1) )
+ {
+ wxLogTrace(_T("iconload"),
+ _T("No small icons found in the file '%s'."),
+ name.c_str());
+ }
+ }
+ //else: not standard size, load below
+
+ if ( !hicon )
+ {
+ // take any (the first one) icon from the file by default
+ hicon = ::ExtractIcon(wxGetInstance(), name1, 0 /* first */);
+ }
+