mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 17:05:45 +00:00
Make LoadCursorIconImage() find shared icons, even if they don't have the desired width/height. Now explorer doesn't leak icons / bitmaps anymore.
fixes bug 1554 See issue #1554 for more details. svn path=/trunk/; revision=25726
This commit is contained in:
parent
cde527ab70
commit
8444d4afb3
1 changed files with 34 additions and 18 deletions
|
@ -186,9 +186,8 @@ LoadCursorIconImage(
|
||||||
UINT fuLoad,
|
UINT fuLoad,
|
||||||
ULONG uType)
|
ULONG uType)
|
||||||
{
|
{
|
||||||
|
HRSRC hResInfo;
|
||||||
HANDLE hResource;
|
HANDLE hResource;
|
||||||
HANDLE h2Resource;
|
|
||||||
HANDLE hfRes;
|
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
HANDLE hSection;
|
HANDLE hSection;
|
||||||
CURSORICONFILEDIR *IconDIR;
|
CURSORICONFILEDIR *IconDIR;
|
||||||
|
@ -211,52 +210,69 @@ LoadCursorIconImage(
|
||||||
if (hinst == NULL)
|
if (hinst == NULL)
|
||||||
hinst = User32Instance;
|
hinst = User32Instance;
|
||||||
|
|
||||||
hResource = hfRes = FindResourceW(hinst, lpszName,
|
hResInfo = FindResourceW(hinst, lpszName,
|
||||||
Icon ? RT_GROUP_ICON : RT_GROUP_CURSOR);
|
Icon ? RT_GROUP_ICON : RT_GROUP_CURSOR);
|
||||||
if (hResource == NULL)
|
if (hResInfo == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (fuLoad & LR_SHARED)
|
hResource = LoadResource(hinst, hResInfo);
|
||||||
{
|
|
||||||
hIcon = NtUserFindExistingCursorIcon(hinst, (HRSRC)hfRes, width, height);
|
|
||||||
if (hIcon)
|
|
||||||
return hIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
hResource = LoadResource(hinst, hResource);
|
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
IconResDir = LockResource(hResource);
|
IconResDir = LockResource(hResource);
|
||||||
if (IconResDir == NULL)
|
if (IconResDir == NULL)
|
||||||
|
{
|
||||||
|
FreeResource(hResource);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find the best fitting in the IconResDir for this resolution */
|
/* Find the best fitting in the IconResDir for this resolution */
|
||||||
id = LookupIconIdFromDirectoryEx((PBYTE)IconResDir, Icon, width, height,
|
id = LookupIconIdFromDirectoryEx((PBYTE)IconResDir, Icon, width, height,
|
||||||
fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
||||||
|
|
||||||
h2Resource = FindResourceW(hinst, MAKEINTRESOURCEW(id),
|
FreeResource(hResource);
|
||||||
|
|
||||||
|
hResInfo = FindResourceW(hinst, MAKEINTRESOURCEW(id),
|
||||||
Icon ? (LPCWSTR) RT_ICON :
|
Icon ? (LPCWSTR) RT_ICON :
|
||||||
(LPCWSTR) RT_CURSOR);
|
(LPCWSTR) RT_CURSOR);
|
||||||
if (h2Resource == NULL)
|
if (hResInfo == NULL)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
hResource = LoadResource(hinst, h2Resource);
|
/* Now we have found the icon we want to load.
|
||||||
|
* Let's see if we already loaded it */
|
||||||
|
if (fuLoad & LR_SHARED)
|
||||||
|
{
|
||||||
|
hIcon = NtUserFindExistingCursorIcon(hinst, hResInfo, 0, 0);
|
||||||
|
if (hIcon)
|
||||||
|
{
|
||||||
|
return hIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hResource = LoadResource(hinst, hResInfo);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ResIcon = LockResource(hResource);
|
ResIcon = LockResource(hResource);
|
||||||
if (ResIcon == NULL)
|
if (ResIcon == NULL)
|
||||||
|
{
|
||||||
|
FreeResource(hResource);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
hIcon = CreateIconFromResourceEx((PBYTE)ResIcon,
|
hIcon = CreateIconFromResourceEx((PBYTE)ResIcon,
|
||||||
SizeofResource(hinst, h2Resource),
|
SizeofResource(hinst, hResInfo),
|
||||||
Icon, 0x00030000, width, height,
|
Icon, 0x00030000, width, height,
|
||||||
fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
||||||
|
FreeResource(hResource);
|
||||||
|
|
||||||
if (hIcon && 0 != (fuLoad & LR_SHARED))
|
if (hIcon && 0 != (fuLoad & LR_SHARED))
|
||||||
{
|
{
|
||||||
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, (HRSRC)hfRes,
|
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, hResInfo,
|
||||||
(HRSRC)NULL);
|
(HRSRC)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue