+ 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 nameReal(name);
+ wxString strIconIndex = name.AfterLast(wxT(';'));
+ if (strIconIndex != name)
+ {
+ iconIndex = wxAtoi(strIconIndex);
+ nameReal = name.BeforeLast(wxT(';'));
+ }
+
+#if 0
+ // If we don't know what size icon we're looking for,
+ // try to find out what's there.
+ // Unfortunately this doesn't work, because ExtractIconEx
+ // will scale the icon to the 'desired' size, even if that
+ // size of icon isn't explicitly stored. So we would have
+ // to parse the icon file outselves.
+ if ( desiredWidth == -1 &&
+ desiredHeight == -1)
+ {
+ // Try loading a large icon first
+ if ( ::ExtractIconEx(nameReal, iconIndex, &hicon, NULL, 1) == 1)
+ {
+ }
+ // Then try loading a small icon
+ else if ( ::ExtractIconEx(nameReal, iconIndex, NULL, &hicon, 1) == 1)
+ {
+ }
+ }
+ else
+#endif
+ // 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(nameReal.t_str(), iconIndex, &hicon, NULL, 1) )
+ {
+ // it is not an error, but it might still be useful to be informed
+ // about it optionally
+ wxLogTrace(wxT("iconload"),
+ wxT("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(nameReal.t_str(), iconIndex, NULL, &hicon, 1) )
+ {
+ wxLogTrace(wxT("iconload"),
+ wxT("No small icons found in the file '%s'."),
+ name.c_str());
+ }
+ }
+ //else: not standard size, load below
+
+#ifndef __WXWINCE__
+ if ( !hicon )
+ {
+ // take any size icon from the file by index
+ hicon = ::ExtractIcon(wxGetInstance(), nameReal.t_str(), iconIndex);
+ }
+#endif
+