server: Moved get/set_thread_context implementation to ptrace.c.
[wine/wine-kai.git] / dlls / ole32 / ole32_main.c
blob1971d0f455a5d1f3db67afcd68d79156ba6b3f7c
1 /*
2 * OLE32 Initialization
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winerror.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "objbase.h"
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)
41 METAFILEPICT mfp;
42 HDC hdc;
43 UINT dy;
44 HGLOBAL hmem = NULL;
45 LPVOID mfdata;
46 static const char szIconOnly[] = "IconOnly";
48 TRACE("%p %p %s %d\n", hIcon, lpszLabel, debugstr_w(lpszSourceFile), iIconIndex);
50 if( !hIcon )
51 return NULL;
53 hdc = CreateMetaFileW(NULL);
54 if( !hdc )
55 return 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);
62 if(lpszLabel)
63 TextOutW(hdc, 0, dy, lpszLabel, lstrlenW(lpszLabel));
65 if (lpszSourceFile)
67 char szIconIndex[10];
68 int path_length = WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,NULL,0,NULL,NULL);
69 if (path_length > 1)
71 char * szPath = CoTaskMemAlloc(path_length * sizeof(CHAR));
72 if (szPath)
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);
86 if( !mfp.hMF )
87 return NULL;
89 hmem = GlobalAlloc( GMEM_MOVEABLE, sizeof(mfp) );
90 if( !hmem )
92 DeleteMetaFile(mfp.hMF);
93 return NULL;
96 mfdata = GlobalLock( hmem );
97 if( !mfdata )
99 GlobalFree( hmem );
100 DeleteMetaFile(mfp.hMF);
101 return NULL;
104 memcpy(mfdata,&mfp,sizeof(mfp));
105 GlobalUnlock( hmem );
107 TRACE("returning %p\n",hmem);
109 return hmem;