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
30 #include "ole32_main.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ole);
35 HINSTANCE OLE32_hInstance = 0;
37 /***********************************************************************
38 * OleMetafilePictFromIconAndLabel (OLE32.@)
40 HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
41 LPOLESTR lpszSourceFile, UINT iIconIndex)
48 static const char szIconOnly[] = "IconOnly";
50 TRACE("%p %p %s %d\n", hIcon, lpszLabel, debugstr_w(lpszSourceFile), iIconIndex);
55 hdc = CreateMetaFileW(NULL);
59 ExtEscape(hdc, MFCOMMENT, sizeof(szIconOnly), szIconOnly, 0, NULL);
61 /* FIXME: things are drawn in the wrong place */
62 DrawIcon(hdc, 0, 0, hIcon);
63 dy = GetSystemMetrics(SM_CXICON);
65 TextOutW(hdc, 0, dy, lpszLabel, lstrlenW(lpszLabel));
70 int path_length = WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,NULL,0,NULL,NULL);
73 char * szPath = CoTaskMemAlloc(path_length * sizeof(CHAR));
76 WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,szPath,path_length,NULL,NULL);
77 ExtEscape(hdc, MFCOMMENT, path_length, szPath, 0, NULL);
78 CoTaskMemFree(szPath);
81 snprintf(szIconIndex, 10, "%u", iIconIndex);
82 ExtEscape(hdc, MFCOMMENT, strlen(szIconIndex)+1, szIconIndex, 0, NULL);
85 mfp.mm = MM_ISOTROPIC;
86 mfp.xExt = mfp.yExt = 0; /* FIXME ? */
87 mfp.hMF = CloseMetaFile(hdc);
91 hmem = GlobalAlloc( GMEM_MOVEABLE, sizeof(mfp) );
94 DeleteMetaFile(mfp.hMF);
98 mfdata = GlobalLock( hmem );
102 DeleteMetaFile(mfp.hMF);
106 memcpy(mfdata,&mfp,sizeof(mfp));
107 GlobalUnlock( hmem );
109 TRACE("returning %p\n",hmem);
115 /***********************************************************************
118 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
120 TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
123 case DLL_PROCESS_ATTACH:
124 DisableThreadLibraryCalls(hinstDLL);
125 OLE32_hInstance = hinstDLL;
126 COMPOBJ_InitProcess();
127 if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);
130 case DLL_PROCESS_DETACH:
131 if (TRACE_ON(ole)) CoRevokeMallocSpy();
132 COMPOBJ_UninitProcess();
139 /* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */