Alexandre Julliard : user: Add internal functions for cursor/icon 16<-> 32 conversion to replace the typecasting macros.
Alexandre Julliard
julliard at winehq.org
Tue Feb 2 10:45:29 CST 2010
Module: wine
Branch: master
Commit: 8fc1fc49fdf1a86bf149c1b03a789e7a493584cd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8fc1fc49fdf1a86bf149c1b03a789e7a493584cd
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Feb 2 12:14:10 2010 +0100
user: Add internal functions for cursor/icon 16<->32 conversion to replace the typecasting macros.
---
dlls/user.exe16/message.c | 14 +++++++-------
dlls/user.exe16/user.c | 34 ++++++++++++++++++++++++----------
dlls/user.exe16/user_private.h | 9 +++------
dlls/user.exe16/window.c | 14 +++++++-------
4 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c
index 1ff58a7..af9da07 100644
--- a/dlls/user.exe16/message.c
+++ b/dlls/user.exe16/message.c
@@ -2619,7 +2619,7 @@ static LRESULT static_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
HICON16 icon = LoadIcon16( HINSTANCE_16(cs->hInstance), cs->lpszName );
if (!icon) icon = LoadCursor16( HINSTANCE_16(cs->hInstance), cs->lpszName );
if (icon) wow_handlers32.static_proc( hwnd, STM_SETIMAGE, IMAGE_ICON,
- (LPARAM)HICON_32(icon), FALSE );
+ (LPARAM)get_icon_32(icon), FALSE );
break;
}
case SS_BITMAP:
@@ -2633,10 +2633,10 @@ static LRESULT static_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
return ret;
}
case STM_SETICON16:
- wParam = (WPARAM)HICON_32( (HICON16)wParam );
+ wParam = (WPARAM)get_icon_32( (HICON16)wParam );
return wow_handlers32.static_proc( hwnd, STM_SETICON, wParam, lParam, FALSE );
case STM_GETICON16:
- return HICON_16( wow_handlers32.static_proc( hwnd, STM_GETICON, wParam, lParam, FALSE ));
+ return get_icon_16( (HICON)wow_handlers32.static_proc( hwnd, STM_GETICON, wParam, lParam, FALSE ));
default:
return wow_handlers32.static_proc( hwnd, msg, wParam, lParam, unicode );
}
@@ -2678,22 +2678,22 @@ static HICON alloc_icon_handle( unsigned int size )
{
HGLOBAL16 handle = GlobalAlloc16( GMEM_MOVEABLE, size );
FarSetOwner16( handle, 0 );
- return HICON_32( handle );
+ return (HICON)(ULONG_PTR)handle;
}
static struct tagCURSORICONINFO *get_icon_ptr( HICON handle )
{
- return GlobalLock16( HICON_16(handle) );
+ return GlobalLock16( LOWORD(handle) );
}
static void release_icon_ptr( HICON handle, struct tagCURSORICONINFO *ptr )
{
- GlobalUnlock16( HICON_16(handle) );
+ GlobalUnlock16( LOWORD(handle) );
}
static int free_icon_handle( HICON handle )
{
- return GlobalFree16( HICON_16(handle) );
+ return GlobalFree16( LOWORD(handle) );
}
diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c
index d415f78..5462d94 100644
--- a/dlls/user.exe16/user.c
+++ b/dlls/user.exe16/user.c
@@ -289,6 +289,16 @@ static int free_icon_handle( HICON16 handle )
return GlobalFree16( handle );
}
+HICON get_icon_32( HICON16 icon16 )
+{
+ return (HICON)(ULONG_PTR)icon16;
+}
+
+HICON16 get_icon_16( HICON icon )
+{
+ return LOWORD( icon );
+}
+
static void add_shared_icon( HINSTANCE16 inst, HRSRC16 rsrc, HRSRC16 group, HICON16 icon )
{
struct cache_entry *cache = HeapAlloc( GetProcessHeap(), 0, sizeof(*cache) );
@@ -471,7 +481,7 @@ BOOL16 WINAPI AnyPopup16(void)
*/
HCURSOR16 WINAPI SetCursor16(HCURSOR16 hCursor)
{
- return HCURSOR_16(SetCursor(HCURSOR_32(hCursor)));
+ return get_icon_16( SetCursor( get_icon_32(hCursor) ));
}
@@ -673,7 +683,7 @@ INT16 WINAPI FrameRect16( HDC16 hdc, const RECT16 *rect16, HBRUSH16 hbrush )
*/
BOOL16 WINAPI DrawIcon16(HDC16 hdc, INT16 x, INT16 y, HICON16 hIcon)
{
- return DrawIcon(HDC_32(hdc), x, y, HICON_32(hIcon));
+ return DrawIcon(HDC_32(hdc), x, y, get_icon_32(hIcon) );
}
@@ -1453,7 +1463,7 @@ BOOL16 WINAPI ExitWindowsExec16( LPCSTR lpszExe, LPCSTR lpszParams )
*/
HCURSOR16 WINAPI GetCursor16(void)
{
- return HCURSOR_16(GetCursor());
+ return get_icon_16( GetCursor() );
}
@@ -1986,7 +1996,12 @@ HANDLE16 WINAPI LoadImage16(HINSTANCE16 hinst, LPCSTR name, UINT16 type, INT16 c
HRSRC16 hRsrc, hGroupRsrc;
if (!hinst || (flags & LR_LOADFROMFILE))
- return HICON_16( LoadImageA( 0, name, type, cx, cy, flags ));
+ {
+ if (type == IMAGE_BITMAP)
+ return HBITMAP_16( LoadImageA( 0, name, type, cx, cy, flags ));
+ else
+ return get_icon_16( LoadImageA( 0, name, type, cx, cy, flags ));
+ }
hinst = GetExePtr( hinst );
@@ -2110,7 +2125,7 @@ BOOL16 WINAPI DrawIconEx16(HDC16 hdc, INT16 xLeft, INT16 yTop, HICON16 hIcon,
INT16 cxWidth, INT16 cyWidth, UINT16 istep,
HBRUSH16 hbr, UINT16 flags)
{
- return DrawIconEx(HDC_32(hdc), xLeft, yTop, HICON_32(hIcon), cxWidth, cyWidth,
+ return DrawIconEx(HDC_32(hdc), xLeft, yTop, get_icon_32(hIcon), cxWidth, cyWidth,
istep, HBRUSH_32(hbr), flags);
}
@@ -2563,8 +2578,7 @@ HICON16 WINAPI CreateIconFromResourceEx16(LPBYTE bits, UINT16 cbSize,
INT16 width, INT16 height,
UINT16 cFlag)
{
- return HICON_16(CreateIconFromResourceEx(bits, cbSize, bIcon, dwVersion,
- width, height, cFlag));
+ return get_icon_16( CreateIconFromResourceEx( bits, cbSize, bIcon, dwVersion, width, height, cFlag ));
}
@@ -2722,7 +2736,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
MSG msg;
LPDRAGINFO16 lpDragInfo;
SEGPTR spDragInfo;
- HCURSOR hOldCursor=0, hBummer=0;
+ HCURSOR hOldCursor=0, hBummer=0, hCursor32;
HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16));
HCURSOR hCurrentCursor = 0;
HWND16 hCurrentWnd = 0;
@@ -2738,7 +2752,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
return 0L;
}
- if(hCursor) hOldCursor = SetCursor(HCURSOR_32(hCursor));
+ if ((hCursor32 = get_icon_32( hCursor ))) SetCursor( hCursor32 );
lpDragInfo->hWnd = hWnd;
lpDragInfo->hScope = 0;
@@ -2761,7 +2775,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
/* update DRAGINFO struct */
if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope), spDragInfo) > 0 )
- hCurrentCursor = HCURSOR_32(hCursor);
+ hCurrentCursor = hCursor32;
else
{
hCurrentCursor = hBummer;
diff --git a/dlls/user.exe16/user_private.h b/dlls/user.exe16/user_private.h
index 97cd669..9c68b85 100644
--- a/dlls/user.exe16/user_private.h
+++ b/dlls/user.exe16/user_private.h
@@ -117,14 +117,11 @@ typedef struct tagDIALOGINFO
#define DF_OWNERENABLED 0x0002
/* HANDLE16 <-> HANDLE conversions */
-#define HCURSOR_16(h32) (LOWORD(h32))
-#define HICON_16(h32) (LOWORD(h32))
#define HINSTANCE_16(h32) (LOWORD(h32))
-
-#define HCURSOR_32(h16) ((HCURSOR)(ULONG_PTR)(h16))
-#define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
#define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
-#define HMODULE_32(h16) ((HMODULE)(ULONG_PTR)(h16))
+
+extern HICON16 get_icon_16( HICON icon ) DECLSPEC_HIDDEN;
+extern HICON get_icon_32( HICON16 icon16 ) DECLSPEC_HIDDEN;
extern DWORD USER16_AlertableWait DECLSPEC_HIDDEN;
extern WORD USER_HeapSel DECLSPEC_HIDDEN;
diff --git a/dlls/user.exe16/window.c b/dlls/user.exe16/window.c
index 0bd4518..b617c4d 100644
--- a/dlls/user.exe16/window.c
+++ b/dlls/user.exe16/window.c
@@ -1575,12 +1575,12 @@ ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
wc32.cbClsExtra = wc->cbClsExtra;
wc32.cbWndExtra = wc->cbWndExtra;
wc32.hInstance = HINSTANCE_32(inst);
- wc32.hIcon = HICON_32(wc->hIcon);
- wc32.hCursor = HCURSOR_32(wc->hCursor);
+ wc32.hIcon = get_icon_32(wc->hIcon);
+ wc32.hCursor = get_icon_32( wc->hCursor );
wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
wc32.lpszMenuName = MapSL(wc->lpszMenuName);
wc32.lpszClassName = MapSL(wc->lpszClassName);
- wc32.hIconSm = HICON_32(wc->hIconSm);
+ wc32.hIconSm = get_icon_32(wc->hIconSm);
atom = RegisterClassExA( &wc32 );
if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
{
@@ -1618,9 +1618,9 @@ BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *
wc->cbClsExtra = wc32.cbClsExtra;
wc->cbWndExtra = wc32.cbWndExtra;
wc->hInstance = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
- wc->hIcon = HICON_16(wc32.hIcon);
- wc->hIconSm = HICON_16(wc32.hIconSm);
- wc->hCursor = HCURSOR_16(wc32.hCursor);
+ wc->hIcon = get_icon_16( wc32.hIcon );
+ wc->hIconSm = get_icon_16( wc32.hIconSm );
+ wc->hCursor = get_icon_16( wc32.hCursor );
wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
wc->lpszClassName = 0;
wc->lpszMenuName = MapLS(wc32.lpszMenuName); /* FIXME: leak */
@@ -2048,7 +2048,7 @@ BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
}
return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
rect ? &rect32 : NULL, HFONT_32(hFont),
- HICON_32(hIcon), str, uFlags & 0x1f );
+ get_icon_32(hIcon), str, uFlags & 0x1f );
}
More information about the wine-cvs
mailing list