user32: Store the module and resource name information for icons.
This commit is contained in:
parent
0df4712658
commit
751a09e983
|
@ -39,6 +39,7 @@
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "user_private.h"
|
#include "user_private.h"
|
||||||
#include "wine/list.h"
|
#include "wine/list.h"
|
||||||
|
#include "wine/unicode.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
|
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
|
||||||
|
@ -114,6 +115,8 @@ struct cursoricon_object
|
||||||
{
|
{
|
||||||
struct user_object obj; /* object header */
|
struct user_object obj; /* object header */
|
||||||
ULONG_PTR param; /* opaque param used by 16-bit code */
|
ULONG_PTR param; /* opaque param used by 16-bit code */
|
||||||
|
HMODULE module; /* module for icons loaded from resources */
|
||||||
|
LPWSTR resname; /* resource name for icons loaded from resources */
|
||||||
BOOL is_icon; /* whether icon or cursor */
|
BOOL is_icon; /* whether icon or cursor */
|
||||||
UINT width;
|
UINT width;
|
||||||
UINT height;
|
UINT height;
|
||||||
|
@ -165,6 +168,7 @@ static BOOL free_icon_handle( HICON handle )
|
||||||
if (obj->frames[i].color) DeleteObject( obj->frames[i].color );
|
if (obj->frames[i].color) DeleteObject( obj->frames[i].color );
|
||||||
DeleteObject( obj->frames[i].mask );
|
DeleteObject( obj->frames[i].mask );
|
||||||
}
|
}
|
||||||
|
if (!IS_INTRESOURCE( obj->resname )) HeapFree( GetProcessHeap(), 0, obj->resname );
|
||||||
HeapFree( GetProcessHeap(), 0, obj );
|
HeapFree( GetProcessHeap(), 0, obj );
|
||||||
if (wow_handlers.free_icon_param && param) wow_handlers.free_icon_param( param );
|
if (wow_handlers.free_icon_param && param) wow_handlers.free_icon_param( param );
|
||||||
USER_Driver->pDestroyCursorIcon( handle );
|
USER_Driver->pDestroyCursorIcon( handle );
|
||||||
|
@ -845,22 +849,13 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
|
static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi, HMODULE module, LPCWSTR resname,
|
||||||
POINT hotspot, BOOL bIcon,
|
POINT hotspot, BOOL bIcon, INT width, INT height, UINT cFlag )
|
||||||
DWORD dwVersion,
|
|
||||||
INT width, INT height,
|
|
||||||
UINT cFlag )
|
|
||||||
{
|
{
|
||||||
HICON hObj;
|
HICON hObj;
|
||||||
HBITMAP color = 0, mask = 0, alpha = 0;
|
HBITMAP color = 0, mask = 0, alpha = 0;
|
||||||
BOOL do_stretch;
|
BOOL do_stretch;
|
||||||
|
|
||||||
if (dwVersion == 0x00020000)
|
|
||||||
{
|
|
||||||
FIXME_(cursor)("\t2.xx resources are not supported\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check bitmap header */
|
/* Check bitmap header */
|
||||||
|
|
||||||
if ( (bmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) &&
|
if ( (bmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) &&
|
||||||
|
@ -899,13 +894,22 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
|
||||||
struct cursoricon_object *info = get_icon_ptr( hObj );
|
struct cursoricon_object *info = get_icon_ptr( hObj );
|
||||||
|
|
||||||
info->is_icon = bIcon;
|
info->is_icon = bIcon;
|
||||||
|
info->module = module;
|
||||||
info->hotspot = hotspot;
|
info->hotspot = hotspot;
|
||||||
info->width = width;
|
info->width = width;
|
||||||
info->height = height;
|
info->height = height;
|
||||||
info->frames[0].color = color;
|
info->frames[0].color = color;
|
||||||
info->frames[0].mask = mask;
|
info->frames[0].mask = mask;
|
||||||
info->frames[0].alpha = alpha;
|
info->frames[0].alpha = alpha;
|
||||||
|
if (!IS_INTRESOURCE(resname))
|
||||||
|
{
|
||||||
|
info->resname = HeapAlloc( GetProcessHeap(), 0, (strlenW(resname) + 1) * sizeof(WCHAR) );
|
||||||
|
if (info->resname) strcpyW( info->resname, resname );
|
||||||
|
}
|
||||||
|
else info->resname = MAKEINTRESOURCEW( LOWORD(resname) );
|
||||||
|
|
||||||
release_icon_ptr( hObj, info );
|
release_icon_ptr( hObj, info );
|
||||||
|
USER_Driver->pCreateCursorIcon( hObj );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1149,7 +1153,6 @@ HICON WINAPI CreateIconFromResourceEx( LPBYTE bits, UINT cbSize,
|
||||||
{
|
{
|
||||||
POINT hotspot;
|
POINT hotspot;
|
||||||
BITMAPINFO *bmi;
|
BITMAPINFO *bmi;
|
||||||
HICON icon;
|
|
||||||
|
|
||||||
TRACE_(cursor)("%p (%u bytes), ver %08x, %ix%i %s %s\n",
|
TRACE_(cursor)("%p (%u bytes), ver %08x, %ix%i %s %s\n",
|
||||||
bits, cbSize, dwVersion, width, height,
|
bits, cbSize, dwVersion, width, height,
|
||||||
|
@ -1157,6 +1160,12 @@ HICON WINAPI CreateIconFromResourceEx( LPBYTE bits, UINT cbSize,
|
||||||
|
|
||||||
if (!bits) return 0;
|
if (!bits) return 0;
|
||||||
|
|
||||||
|
if (dwVersion == 0x00020000)
|
||||||
|
{
|
||||||
|
FIXME_(cursor)("\t2.xx resources are not supported\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (bIcon)
|
if (bIcon)
|
||||||
{
|
{
|
||||||
hotspot.x = width / 2;
|
hotspot.x = width / 2;
|
||||||
|
@ -1171,10 +1180,7 @@ HICON WINAPI CreateIconFromResourceEx( LPBYTE bits, UINT cbSize,
|
||||||
bmi = (BITMAPINFO *)(pt + 2);
|
bmi = (BITMAPINFO *)(pt + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
icon = CURSORICON_CreateIconFromBMI( bmi, hotspot, bIcon, dwVersion,
|
return CURSORICON_CreateIconFromBMI( bmi, NULL, NULL, hotspot, bIcon, width, height, cFlag );
|
||||||
width, height, cFlag );
|
|
||||||
if (icon) USER_Driver->pCreateCursorIcon( icon );
|
|
||||||
return icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1236,13 +1242,11 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
|
||||||
|
|
||||||
hotspot.x = entry->xHotspot;
|
hotspot.x = entry->xHotspot;
|
||||||
hotspot.y = entry->yHotspot;
|
hotspot.y = entry->yHotspot;
|
||||||
hIcon = CURSORICON_CreateIconFromBMI( (BITMAPINFO *)&bits[entry->dwDIBOffset],
|
hIcon = CURSORICON_CreateIconFromBMI( (BITMAPINFO *)&bits[entry->dwDIBOffset], NULL, NULL,
|
||||||
hotspot, !fCursor, 0x00030000,
|
hotspot, !fCursor, width, height, loadflags );
|
||||||
width, height, loadflags );
|
|
||||||
end:
|
end:
|
||||||
TRACE("loaded %s -> %p\n", debugstr_w( filename ), hIcon );
|
TRACE("loaded %s -> %p\n", debugstr_w( filename ), hIcon );
|
||||||
UnmapViewOfFile( bits );
|
UnmapViewOfFile( bits );
|
||||||
if (hIcon) USER_Driver->pCreateCursorIcon( hIcon );
|
|
||||||
return hIcon;
|
return hIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,6 +1267,7 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name,
|
||||||
LPBYTE bits;
|
LPBYTE bits;
|
||||||
WORD wResId;
|
WORD wResId;
|
||||||
DWORD dwBytesInRes;
|
DWORD dwBytesInRes;
|
||||||
|
POINT hotspot;
|
||||||
|
|
||||||
TRACE("%p, %s, %dx%d, depth %d, fCursor %d, flags 0x%04x\n",
|
TRACE("%p, %s, %dx%d, depth %d, fCursor %d, flags 0x%04x\n",
|
||||||
hInstance, debugstr_w(name), width, height, depth, fCursor, loadflags);
|
hInstance, debugstr_w(name), width, height, depth, fCursor, loadflags);
|
||||||
|
@ -1307,8 +1312,21 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name,
|
||||||
|
|
||||||
if (!(handle = LoadResource( hInstance, hRsrc ))) return 0;
|
if (!(handle = LoadResource( hInstance, hRsrc ))) return 0;
|
||||||
bits = LockResource( handle );
|
bits = LockResource( handle );
|
||||||
hIcon = CreateIconFromResourceEx( bits, dwBytesInRes,
|
|
||||||
!fCursor, 0x00030000, width, height, loadflags);
|
if (!fCursor)
|
||||||
|
{
|
||||||
|
hotspot.x = width / 2;
|
||||||
|
hotspot.y = height / 2;
|
||||||
|
}
|
||||||
|
else /* get the hotspot */
|
||||||
|
{
|
||||||
|
SHORT *pt = (SHORT *)bits;
|
||||||
|
hotspot.x = pt[0];
|
||||||
|
hotspot.y = pt[1];
|
||||||
|
bits += 2 * sizeof(SHORT);
|
||||||
|
}
|
||||||
|
hIcon = CURSORICON_CreateIconFromBMI( (BITMAPINFO *)bits, hInstance, name, hotspot,
|
||||||
|
!fCursor, width, height, loadflags );
|
||||||
FreeResource( handle );
|
FreeResource( handle );
|
||||||
|
|
||||||
/* If shared icon, add to icon cache */
|
/* If shared icon, add to icon cache */
|
||||||
|
|
Loading…
Reference in New Issue