Alexandre Julliard : ole2: Convert the icon for OleMetafilePictFromIconAndLabel to 32-bit explicitly instead of casting the handle .

Alexandre Julliard julliard at winehq.org
Tue Jan 5 11:37:50 CST 2010


Module: wine
Branch: master
Commit: 25c2236a91e889e3f50513048e51bb94894c6d8c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=25c2236a91e889e3f50513048e51bb94894c6d8c

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jan  4 20:26:54 2010 +0100

ole2: Convert the icon for OleMetafilePictFromIconAndLabel to 32-bit explicitly instead of casting the handle.

---

 dlls/ole2.dll16/ole2.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/ole2.dll16/ole2.c b/dlls/ole2.dll16/ole2.c
index d3880c6..c158949 100644
--- a/dlls/ole2.dll16/ole2.c
+++ b/dlls/ole2.dll16/ole2.c
@@ -48,8 +48,17 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 
-#define HICON_16(h32)		(LOWORD(h32))
-#define HICON_32(h16)		((HICON)(ULONG_PTR)(h16))
+
+static HICON convert_icon_to_32( HICON16 icon16 )
+{
+    CURSORICONINFO *info = GlobalLock16( icon16 );
+    void *and_bits = info + 1;
+    void *xor_bits = (BYTE *)and_bits + info->nHeight * 2 * ((info->nWidth + 15) / 16);
+    HICON ret = CreateIcon( 0, info->nWidth, info->nHeight, info->bPlanes, info->bBitsPerPixel,
+                            and_bits, xor_bits );
+    GlobalUnlock16( icon16 );
+    return ret;
+}
 
 /******************************************************************************
  *		OleBuildVersion	(OLE2.1)
@@ -124,7 +133,7 @@ HRESULT WINAPI RevokeDragDrop16(
  * This code might be wrong at some places.
  */
 HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
-	HICON16 hIcon,
+	HICON16 icon16,
 	LPCOLESTR16 lpszLabel,
 	LPCOLESTR16 lpszSourceFile,
 	UINT16 iIconIndex
@@ -134,6 +143,7 @@ HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
     HGLOBAL16 hmf16;
     LPWSTR label = NULL, source = NULL;
     DWORD len;
+    HICON icon = convert_icon_to_32( icon16 );
 
     if (lpszLabel)
     {
@@ -147,9 +157,10 @@ HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
         source = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
         MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, source, len );
     }
-    hmf = OleMetafilePictFromIconAndLabel( HICON_32(hIcon), label, source, iIconIndex );
+    hmf = OleMetafilePictFromIconAndLabel( icon, label, source, iIconIndex );
     HeapFree( GetProcessHeap(), 0, label );
     HeapFree( GetProcessHeap(), 0, source );
+    DestroyIcon( icon );
 
     if (!hmf) return 0;
     pict = GlobalLock( hmf );




More information about the wine-cvs mailing list