| 324 | } |
| 325 | |
| 326 | HICON |
| 327 | LoadLocalizedIconEx(const UINT iconId, int cxDesired, int cyDesired) |
| 328 | { |
| 329 | LANGID langId = GetGUILanguage(); |
| 330 | |
| 331 | HICON hIcon = (HICON)LoadImage(o.hInstance, |
| 332 | MAKEINTRESOURCE(iconId), |
| 333 | IMAGE_ICON, |
| 334 | cxDesired, |
| 335 | cyDesired, |
| 336 | LR_DEFAULTSIZE | LR_SHARED); |
| 337 | if (hIcon) |
| 338 | { |
| 339 | return hIcon; |
| 340 | } |
| 341 | else |
| 342 | { |
| 343 | PrintDebug(L"Loading icon using LoadImage failed."); |
| 344 | } |
| 345 | |
| 346 | /* Fallback to CreateIconFromResource which always scales |
| 347 | * from the first image in the resource |
| 348 | */ |
| 349 | /* find group icon resource */ |
| 350 | HRSRC res = FindResourceLang(RT_GROUP_ICON, MAKEINTRESOURCE(iconId), langId); |
| 351 | if (res == NULL) |
| 352 | { |
| 353 | return NULL; |
| 354 | } |
| 355 | |
| 356 | HGLOBAL resInfo = LoadResource(o.hInstance, res); |
| 357 | if (resInfo == NULL) |
| 358 | { |
| 359 | return NULL; |
| 360 | } |
| 361 | |
| 362 | int id = LookupIconIdFromDirectory(resInfo, TRUE); |
| 363 | if (id == 0) |
| 364 | { |
| 365 | return NULL; |
| 366 | } |
| 367 | |
| 368 | /* find the actual icon */ |
| 369 | res = FindResourceLang(RT_ICON, MAKEINTRESOURCE(id), langId); |
| 370 | if (res == NULL) |
| 371 | { |
| 372 | return NULL; |
| 373 | } |
| 374 | |
| 375 | resInfo = LoadResource(o.hInstance, res); |
| 376 | if (resInfo == NULL) |
| 377 | { |
| 378 | return NULL; |
| 379 | } |
| 380 | |
| 381 | DWORD resSize = SizeofResource(o.hInstance, res); |
| 382 | if (resSize == 0) |
| 383 | { |
no test coverage detected