4 * Copyright 2000 Huw D M Davies for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ole);
35 /***********************************************************************
36 * OleMetafilePictFromIconAndLabel (OLE32.@)
38 HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
39 LPOLESTR lpszSourceFile, UINT iIconIndex)
46 static const char szIconOnly[] = "IconOnly";
48 TRACE("%p %p %s %d\n", hIcon, lpszLabel, debugstr_w(lpszSourceFile), iIconIndex);
53 hdc = CreateMetaFileW(NULL);
57 ExtEscape(hdc, MFCOMMENT, sizeof(szIconOnly), szIconOnly, 0, NULL);
59 /* FIXME: things are drawn in the wrong place */
60 DrawIcon(hdc, 0, 0, hIcon);
61 dy = GetSystemMetrics(SM_CXICON);
63 TextOutW(hdc, 0, dy, lpszLabel, lstrlenW(lpszLabel));
68 int path_length = WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,NULL,0,NULL,NULL);
71 char * szPath = CoTaskMemAlloc(path_length * sizeof(CHAR));
74 WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,szPath,path_length,NULL,NULL);
75 ExtEscape(hdc, MFCOMMENT, path_length, szPath, 0, NULL);
76 CoTaskMemFree(szPath);
79 snprintf(szIconIndex, 10, "%u", iIconIndex);
80 ExtEscape(hdc, MFCOMMENT, strlen(szIconIndex)+1, szIconIndex, 0, NULL);
83 mfp.mm = MM_ISOTROPIC;
84 mfp.xExt = mfp.yExt = 0; /* FIXME ? */
85 mfp.hMF = CloseMetaFile(hdc);
89 hmem = GlobalAlloc( GMEM_MOVEABLE, sizeof(mfp) );
92 DeleteMetaFile(mfp.hMF);
96 mfdata = GlobalLock( hmem );
100 DeleteMetaFile(mfp.hMF);
104 memcpy(mfdata,&mfp,sizeof(mfp));
105 GlobalUnlock( hmem );
107 TRACE("returning %p\n",hmem);