Commit 91fde249 authored by Alexandre Julliard's avatar Alexandre Julliard

ole2: Reimplement OleMetafilePictFromIconAndLabel16 on top of the 32-bit version.

parent 55f024af
...@@ -50,7 +50,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); ...@@ -50,7 +50,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
#define HICON_16(h32) (LOWORD(h32)) #define HICON_16(h32) (LOWORD(h32))
#define HICON_32(h16) ((HICON)(ULONG_PTR)(h16)) #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
#define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
/****************************************************************************** /******************************************************************************
* OleBuildVersion (OLE2.1) * OleBuildVersion (OLE2.1)
...@@ -124,49 +123,53 @@ HRESULT WINAPI RevokeDragDrop16( ...@@ -124,49 +123,53 @@ HRESULT WINAPI RevokeDragDrop16(
* If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex. * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
* This code might be wrong at some places. * This code might be wrong at some places.
*/ */
HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
HICON16 hIcon, HICON16 hIcon,
LPCOLESTR16 lpszLabel, LPCOLESTR16 lpszLabel,
LPCOLESTR16 lpszSourceFile, LPCOLESTR16 lpszSourceFile,
UINT16 iIconIndex UINT16 iIconIndex
) { ) {
METAFILEPICT16 *mf16; METAFILEPICT *pict;
HGLOBAL hmf;
HGLOBAL16 hmf16; HGLOBAL16 hmf16;
HMETAFILE hmf; LPWSTR label = NULL, source = NULL;
INT mfSize; DWORD len;
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;
}
FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", if (lpszLabel)
hIcon, lpszLabel, lpszSourceFile, iIconIndex); {
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); if (!hmf) return 0;
DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */ pict = GlobalLock( hmf );
TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */
hmf = CloseMetaFile(hdc);
hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16)); hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
mf16 = GlobalLock16(hmf16); if (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)
{ {
GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF)); METAFILEPICT16 *pict16 = GlobalLock16( hmf16 );
GlobalUnlock16(mf16->hMF); 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; return hmf16;
} }
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
53 stub OLEGETICONOFCLASS 53 stub OLEGETICONOFCLASS
54 pascal CreateILockBytesOnHGlobal(word word ptr) CreateILockBytesOnHGlobal16 54 pascal CreateILockBytesOnHGlobal(word word ptr) CreateILockBytesOnHGlobal16
55 stub GETHGLOBALFROMILOCKBYTES 55 stub GETHGLOBALFROMILOCKBYTES
56 pascal -ret16 OleMetaFilePictFromIconAndLabel(word str str word) OleMetaFilePictFromIconAndLabel16 56 pascal -ret16 OleMetafilePictFromIconAndLabel(word str str word) OleMetafilePictFromIconAndLabel16
57 stub GETCLASSFILE 57 stub GETCLASSFILE
58 stub OLEDRAW 58 stub OLEDRAW
59 stub OLECREATEDEFAULTHANDLER 59 stub OLECREATEDEFAULTHANDLER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment