added LR_SHARED flag support for LoadIcon() and LoadCursor()

svn path=/trunk/; revision=6689
This commit is contained in:
Thomas Bluemel 2003-11-18 19:59:51 +00:00
parent 7fd98f181c
commit 69a485aba7
4 changed files with 100 additions and 39 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: bitmap.c,v 1.19 2003/11/10 17:44:49 weiden Exp $ /* $Id: bitmap.c,v 1.20 2003/11/18 19:59:50 weiden Exp $
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c * FILE: lib/user32/windows/input.c
@ -80,6 +80,7 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
{ {
HANDLE hResource; HANDLE hResource;
HANDLE h2Resource; HANDLE h2Resource;
HANDLE hfRes;
HANDLE hFile; HANDLE hFile;
HANDLE hSection; HANDLE hSection;
CURSORICONDIR* IconDIR; CURSORICONDIR* IconDIR;
@ -94,21 +95,25 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
INT id; INT id;
ICONIMAGE *ResIcon; ICONIMAGE *ResIcon;
if (fuLoad & LR_SHARED)
DbgPrint("FIXME: need LR_SHARED support Loading cursor images\n");
if (!(fuLoad & LR_LOADFROMFILE)) if (!(fuLoad & LR_LOADFROMFILE))
{ {
if (hinst == NULL) if (hinst == NULL)
{ {
hinst = GetModuleHandleW(L"USER32"); hinst = GetModuleHandleW(L"USER32");
} }
hResource = FindResourceW(hinst, lpszName, RT_GROUP_CURSOR); hResource = hfRes = FindResourceW(hinst, lpszName, RT_GROUP_CURSOR);
if (hResource == NULL) if (hResource == NULL)
{ {
return(NULL); return(NULL);
} }
if (fuLoad & LR_SHARED)
{
hIcon = (HANDLE)NtUserFindExistingCursorIcon(hinst, (HRSRC)hfRes);
if(hIcon)
return hIcon;
}
hResource = LoadResource(hinst, hResource); hResource = LoadResource(hinst, hResource);
if (hResource == NULL) if (hResource == NULL)
{ {
@ -139,12 +144,23 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
{ {
return(NULL); return(NULL);
} }
return CreateIconFromResourceEx((PBYTE) ResIcon, hIcon = (HANDLE)CreateIconFromResourceEx((PBYTE) ResIcon,
SizeofResource(hinst, h2Resource), FALSE, 0x00030000, SizeofResource(hinst, h2Resource), FALSE, 0x00030000,
32, 32, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME)); 32, 32, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
if(hIcon)
{
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, (HRSRC)hfRes,
(HRSRC)NULL);
}
return hIcon;
} }
else else
{ {
if (fuLoad & LR_SHARED)
{
DbgPrint("FIXME: need LR_SHARED support loading cursor images from files\n");
}
hFile = CreateFileW(lpszName, hFile = CreateFileW(lpszName,
GENERIC_READ, GENERIC_READ,
FILE_SHARE_READ, FILE_SHARE_READ,
@ -246,6 +262,7 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
{ {
HANDLE hResource; HANDLE hResource;
HANDLE h2Resource; HANDLE h2Resource;
HANDLE hfRes;
HANDLE hFile; HANDLE hFile;
HANDLE hSection; HANDLE hSection;
CURSORICONDIR* IconDIR; CURSORICONDIR* IconDIR;
@ -260,21 +277,25 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
INT id; INT id;
ICONIMAGE *ResIcon; ICONIMAGE *ResIcon;
if (fuLoad & LR_SHARED)
DbgPrint("FIXME: need LR_SHARED support Loading icon images\n");
if (!(fuLoad & LR_LOADFROMFILE)) if (!(fuLoad & LR_LOADFROMFILE))
{ {
if (hinst == NULL) if (hinst == NULL)
{ {
hinst = GetModuleHandleW(L"USER32"); hinst = GetModuleHandleW(L"USER32");
} }
hResource = FindResourceW(hinst, lpszName, RT_GROUP_ICON); hResource = hfRes = FindResourceW(hinst, lpszName, RT_GROUP_ICON);
if (hResource == NULL) if (hResource == NULL)
{ {
return(NULL); return(NULL);
} }
if (fuLoad & LR_SHARED)
{
hIcon = NtUserFindExistingCursorIcon(hinst, (HRSRC)hfRes);
if(hIcon)
return hIcon;
}
hResource = LoadResource(hinst, hResource); hResource = LoadResource(hinst, hResource);
if (hResource == NULL) if (hResource == NULL)
{ {
@ -305,12 +326,23 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
{ {
return(NULL); return(NULL);
} }
return CreateIconFromResourceEx((PBYTE) ResIcon, hIcon = (HANDLE)CreateIconFromResourceEx((PBYTE) ResIcon,
SizeofResource(hinst, h2Resource), TRUE, 0x00030000, SizeofResource(hinst, h2Resource), TRUE, 0x00030000,
width, height, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME)); width, height, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
if(hIcon)
{
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, (HRSRC)hfRes,
(HRSRC)NULL);
}
return hIcon;
} }
else else
{ {
if (fuLoad & LR_SHARED)
{
DbgPrint("FIXME: need LR_SHARED support for loading icon images from files\n");
}
hFile = CreateFileW(lpszName, hFile = CreateFileW(lpszName,
GENERIC_READ, GENERIC_READ,
FILE_SHARE_READ, FILE_SHARE_READ,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: cursor.c,v 1.14 2003/11/10 17:44:49 weiden Exp $ /* $Id: cursor.c,v 1.15 2003/11/18 19:59:51 weiden Exp $
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/cursor.c * FILE: lib/user32/windows/cursor.c
@ -176,7 +176,7 @@ LoadCursorA(HINSTANCE hInstance,
LPCSTR lpCursorName) LPCSTR lpCursorName)
{ {
return(LoadImageA(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0, return(LoadImageA(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0,
LR_DEFAULTSIZE)); LR_SHARED | LR_DEFAULTSIZE));
} }
@ -215,7 +215,7 @@ LoadCursorW(HINSTANCE hInstance,
LPCWSTR lpCursorName) LPCWSTR lpCursorName)
{ {
return(LoadImageW(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0, return(LoadImageW(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0,
LR_DEFAULTSIZE)); LR_SHARED | LR_DEFAULTSIZE));
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: icon.c,v 1.13 2003/11/10 17:44:49 weiden Exp $ /* $Id: icon.c,v 1.14 2003/11/18 19:59:51 weiden Exp $
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/icon.c * FILE: lib/user32/windows/icon.c
@ -243,6 +243,15 @@ CreateIconFromResourceEx(
WORD wXHotspot; WORD wXHotspot;
WORD wYHotspot; WORD wYHotspot;
/*
FIXME - does win support LR_SHARED? According to msdn it does but we don't
have useful information to identify the icon
if (uFlags & LR_SHARED)
{
DbgPrint("FIXME: need LR_SHARED support in CreateIconFromResourceEx()\n");
}
*/
DPRINT("dwVersion, cxDesired, cyDesired are all ignored in this implementation!\n"); DPRINT("dwVersion, cxDesired, cyDesired are all ignored in this implementation!\n");
if (! fIcon) if (! fIcon)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: cursoricon.c,v 1.19 2003/11/15 12:43:25 weiden Exp $ */ /* $Id: cursoricon.c,v 1.20 2003/11/18 19:59:51 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
@ -469,8 +469,8 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect)
CurIconObject->IconInfo.hbmMask = IntCopyBitmap(CurIconObject->IconInfo.hbmMask); CurIconObject->IconInfo.hbmMask = IntCopyBitmap(CurIconObject->IconInfo.hbmMask);
CurIconObject->IconInfo.hbmColor = IntCopyBitmap(CurIconObject->IconInfo.hbmColor); CurIconObject->IconInfo.hbmColor = IntCopyBitmap(CurIconObject->IconInfo.hbmColor);
} }
bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor); if(CurIconObject->IconInfo.hbmColor &&
if(bmp) (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor)))
{ {
CurIconObject->Size.cx = bmp->size.cx; CurIconObject->Size.cx = bmp->size.cx;
CurIconObject->Size.cy = bmp->size.cy; CurIconObject->Size.cy = bmp->size.cy;
@ -478,8 +478,8 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect)
} }
else else
{ {
bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask); if(CurIconObject->IconInfo.hbmMask &&
if(bmp) (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask)))
{ {
CurIconObject->Size.cx = bmp->size.cx; CurIconObject->Size.cx = bmp->size.cx;
CurIconObject->Size.cy = bmp->size.cy / 2; CurIconObject->Size.cy = bmp->size.cy / 2;
@ -1036,12 +1036,23 @@ NtUserSetCursorIconData(
if(CurIconObject) if(CurIconObject)
{ {
/* Copy fields */ /* Copy fields */
if(fIcon)
{
Status = MmCopyFromCaller(&CurIconObject->IconInfo.fIcon, fIcon, sizeof(BOOL)); Status = MmCopyFromCaller(&CurIconObject->IconInfo.fIcon, fIcon, sizeof(BOOL));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
goto done; goto done;
} }
}
else
{
if(!Hotspot)
Ret = TRUE;
}
if(Hotspot)
{
Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT)); Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT));
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
@ -1056,6 +1067,15 @@ NtUserSetCursorIconData(
} }
else else
SetLastNtError(Status); SetLastNtError(Status);
}
if(!fIcon && !Hotspot)
{
CurIconObject->hModule = hModule;
CurIconObject->hRsrc = hRsrc;
CurIconObject->hGroupRsrc = hGroupRsrc;
Ret = TRUE;
}
done: done:
IntReleaseCurIconObject(WinStaObject); IntReleaseCurIconObject(WinStaObject);