diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index ca02625d59a..f3fe6992370 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -112,7 +112,7 @@ 112 stdcall OleLoad(ptr ptr ptr ptr) 113 stdcall OleLoadFromStream(ptr ptr ptr) 114 stdcall OleLockRunning(ptr long long) -115 stub OleMetafilePictFromIconAndLabel +115 stdcall OleMetafilePictFromIconAndLabel(long ptr ptr long) 116 stub OleNoteObjectVisible 117 stdcall OleQueryCreateFromData(ptr) 118 stdcall OleQueryLinkFromData(ptr) diff --git a/dlls/ole32/ole32_main.c b/dlls/ole32/ole32_main.c index d2720ae5760..1e2a985cf2c 100644 --- a/dlls/ole32/ole32_main.c +++ b/dlls/ole32/ole32_main.c @@ -20,6 +20,9 @@ #include "windef.h" #include "winerror.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" #include "ole32_main.h" #include "wine/debug.h" @@ -27,10 +30,67 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); HINSTANCE OLE32_hInstance = 0; +/*********************************************************************** + * OleMetafilePictFromIconAndLabel (OLE32.115) + */ +HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel, + LPOLESTR lpszSourceFile, UINT iIconIndex) +{ + HMETAFILE hmf; + HDC hdc; + UINT dy, mfsize; + HGLOBAL hmem = 0; + LPVOID mfdata; + + TRACE("%p %p %p %d\n", hIcon, lpszLabel, lpszSourceFile, iIconIndex); + + if( !hIcon ) + return 0; + + hdc = CreateMetaFileW(NULL); + if( !hdc ) + return 0; + + /* FIXME: things are drawn in the wrong place */ + DrawIcon(hdc, 0, 0, hIcon); + dy = GetSystemMetrics(SM_CXICON); + if(lpszLabel) + TextOutW(hdc, 0, dy, lpszLabel, lstrlenW(lpszLabel)); + + hmf = CloseMetaFile(hdc); + if( !hmf ) + return 0; + + mfsize = GetMetaFileBitsEx( hmf, 0, NULL); + if( !mfsize ) + goto end; + + hmem = GlobalAlloc( GMEM_MOVEABLE, mfsize ); + if( !hmem ) + goto end; + + mfdata = GlobalLock( hmem ); + if( !mfdata ) + { + GlobalFree( hmem ); + hmem = 0; + goto end; + } + + GetMetaFileBitsEx( hmf, mfsize, mfdata ); + GlobalUnlock( hmem ); +end: + DeleteMetaFile(hmf); + + TRACE("returning %p\n",hmem); + + return hmem; +} + + /*********************************************************************** * DllMain (OLE32.@) */ - BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) { TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);