Module: wine Branch: master Commit: 91fde2494cc01d2ee91e0776901cd0f3294d5963 URL: http://source.winehq.org/git/wine.git/?a=commit;h=91fde2494cc01d2ee91e077690...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Dec 23 17:11:24 2009 +0100
ole2: Reimplement OleMetafilePictFromIconAndLabel16 on top of the 32-bit version.
---
dlls/ole2.dll16/ole2.c | 67 ++++++++++++++++++++------------------ dlls/ole2.dll16/ole2.dll16.spec | 2 +- 2 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/dlls/ole2.dll16/ole2.c b/dlls/ole2.dll16/ole2.c index ab04390..d3880c6 100644 --- a/dlls/ole2.dll16/ole2.c +++ b/dlls/ole2.dll16/ole2.c @@ -50,7 +50,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
#define HICON_16(h32) (LOWORD(h32)) #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16)) -#define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
/****************************************************************************** * OleBuildVersion (OLE2.1) @@ -124,49 +123,53 @@ HRESULT WINAPI RevokeDragDrop16( * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex. * This code might be wrong at some places. */ -HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( +HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16( HICON16 hIcon, LPCOLESTR16 lpszLabel, LPCOLESTR16 lpszSourceFile, UINT16 iIconIndex ) { - METAFILEPICT16 *mf16; + METAFILEPICT *pict; + HGLOBAL hmf; HGLOBAL16 hmf16; - HMETAFILE hmf; - INT mfSize; - HDC hdc; - - if (!hIcon) { - if (lpszSourceFile) { - HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile); - - /* load the icon at index from lpszSourceFile */ - hIcon = HICON_16(LoadIconA(HINSTANCE_32(hInstance), (LPCSTR)(DWORD)iIconIndex)); - FreeLibrary16(hInstance); - } else - return 0; - } + LPWSTR label = NULL, source = NULL; + DWORD len;
- FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", - hIcon, lpszLabel, lpszSourceFile, iIconIndex); + if (lpszLabel) + { + len = MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, NULL, 0 ); + label = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, label, len ); + } + if (lpszSourceFile) + { + len = MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, NULL, 0 ); + source = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, source, len ); + } + hmf = OleMetafilePictFromIconAndLabel( HICON_32(hIcon), label, source, iIconIndex ); + HeapFree( GetProcessHeap(), 0, label ); + HeapFree( GetProcessHeap(), 0, source );
- hdc = CreateMetaFileW(NULL); - DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */ - TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */ - hmf = CloseMetaFile(hdc); + if (!hmf) return 0; + pict = GlobalLock( hmf );
hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16)); - mf16 = GlobalLock16(hmf16); - mf16->mm = MM_ANISOTROPIC; - mf16->xExt = 20; /* FIXME: bogus */ - mf16->yExt = 20; /* ditto */ - mfSize = GetMetaFileBitsEx(hmf, 0, 0); - mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize); - if(mf16->hMF) + if (hmf16) { - GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF)); - GlobalUnlock16(mf16->hMF); + METAFILEPICT16 *pict16 = GlobalLock16( hmf16 ); + pict16->mm = pict->mm; + pict16->xExt = pict->xExt; + pict16->yExt = pict->yExt; + len = GetMetaFileBitsEx( pict->hMF, 0, 0 ); + pict16->hMF = GlobalAlloc16( GMEM_MOVEABLE, len ); + GetMetaFileBitsEx( pict->hMF, len, GlobalLock16( pict16->hMF) ); + GlobalUnlock16( pict16->hMF ); + GlobalUnlock16( hmf16 ); } + DeleteMetaFile( pict->hMF ); + GlobalUnlock( hmf ); + GlobalFree( hmf ); return hmf16; }
diff --git a/dlls/ole2.dll16/ole2.dll16.spec b/dlls/ole2.dll16/ole2.dll16.spec index 6f08851..308f77a 100644 --- a/dlls/ole2.dll16/ole2.dll16.spec +++ b/dlls/ole2.dll16/ole2.dll16.spec @@ -53,7 +53,7 @@ 53 stub OLEGETICONOFCLASS 54 pascal CreateILockBytesOnHGlobal(word word ptr) CreateILockBytesOnHGlobal16 55 stub GETHGLOBALFROMILOCKBYTES -56 pascal -ret16 OleMetaFilePictFromIconAndLabel(word str str word) OleMetaFilePictFromIconAndLabel16 +56 pascal -ret16 OleMetafilePictFromIconAndLabel(word str str word) OleMetafilePictFromIconAndLabel16 57 stub GETCLASSFILE 58 stub OLEDRAW 59 stub OLECREATEDEFAULTHANDLER