reactos/reactos/lib/ole32/ole32_main.c

111 lines
3 KiB
C
Raw Normal View History

/*
* OLE32 Initialization
*
* Copyright 2000 Huw D M Davies for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winerror.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
Sync to Wine-20050524: Alexandre Julliard <julliard@winehq.org> - Added rules for building import libraries in the individual dll makefiles, and added support for building a .def.a static import library too. - Removed unnecessary code in the 16-bit DllEntryPoint function of some dlls, and also fixed its ordinal in a few places. - Comment out stub WEP entry points so that we can call WEP for builtin dlls too. Juan Lang <juan_lang@yahoo.com> - Obvious fixes to PropVariantClear and PropVariantCopy for vector types. - Add a comment, and a no-op cleanup. - Differentiate between version 0 and version 1 property storages. - Store property names in the code page of the property set. - maintain proper byte order - maintain PROPSETFLAG_ANSI flag based on codepage - update comments - Correct/improve error checking in IPropertyStorage. - convert strings between property storage's code page and system code page - add tests for setting code page - fix tests and behavior to match WinXP - Define and use endian conversion macros for big-endian machines. Marcus Meissner <marcus@jet.franken.de> - Move the Dll init function to compobj.c to avoid having global variables. Remove need of ole32_main.h. - Make HGLOBALStream_* functions static. - Make _xmalloc16() static. - Staticify FTMarshalImpl definition. Francois Gouget <fgouget@free.fr> - Specify the proper call convention in the PropSysFreeString() implementation. - Tweak the API documentation to silence winapi_check warnings. Robert Shearman <rob@codeweavers.com> - Add error messages on failure in file moniker load function. - Fix incorrect pointer check in both monikers. - Fix max size calculation of item moniker to match native. - Add a generic moniker marshaler that works by saving & loading monikers to & from the stream. - Use the generic moniker marshal in the file & item monikers and add a class factory for each. - Implement IROTData::GetComparisonData for file & item monikers. - Add a useful trace message. - Fix more places where custom header size was calculated exclusive of the data size member. - Optimize custom marshaling by getting size before calling the custom marshaler so we can write the header before and not use a second stream. - Change remaining blocks of code with 2-space indentation to 4-space indentation. - Make vtables const. - Remove an unnecessary memcpy and let the compiler do the work. - Write custom header up to and including size, not excluding. - Add a stub implementation of CoIsHandlerConnected. - Marshal objects & monikers into the ROT. - Test for this behaviour. Mike McCormack <mike@codeweavers.com> - Remove unnecessary declarations and make functions static. - Remove forward declarations. - Make sure a stream can't be created in read only storage. - Fix a memory leak in the ole storage implementation. - Remove function prototypes. Kevin Koltzau <kevin@plop.org> - Implement Hash function on composite moniker. Jeff Latimer <jeffl@defcen.gov.au> - Implement the IEnumMoniker interface for the ROT and provide tests to exercise the interface. Pierre d'Herbemont <stegefin@free.fr> - Big Endian specific code fixes in order to conform with NONAMELESSSTRUCT. Matthew Mastracci <matt@aclaro.com> - Replace stub entry for StgOpenStorageEx with call to StgOpenStorage. - Replace StgCreateStorageEx stub with call to StgCreateDocfile and add required STGFMT_* enumerations. svn path=/trunk/; revision=15562
2005-05-28 09:30:04 +00:00
#include "objbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
/***********************************************************************
* OleMetafilePictFromIconAndLabel (OLE32.@)
*/
HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
LPOLESTR lpszSourceFile, UINT iIconIndex)
{
METAFILEPICT mfp;
HDC hdc;
UINT dy;
HGLOBAL hmem = NULL;
LPVOID mfdata;
static const char szIconOnly[] = "IconOnly";
TRACE("%p %p %s %d\n", hIcon, lpszLabel, debugstr_w(lpszSourceFile), iIconIndex);
if( !hIcon )
return NULL;
hdc = CreateMetaFileW(NULL);
if( !hdc )
return NULL;
ExtEscape(hdc, MFCOMMENT, sizeof(szIconOnly), szIconOnly, 0, NULL);
/* 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));
if (lpszSourceFile)
{
char szIconIndex[10];
int path_length = WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,NULL,0,NULL,NULL);
if (path_length > 1)
{
char * szPath = CoTaskMemAlloc(path_length * sizeof(CHAR));
if (szPath)
{
WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,szPath,path_length,NULL,NULL);
ExtEscape(hdc, MFCOMMENT, path_length, szPath, 0, NULL);
CoTaskMemFree(szPath);
}
}
snprintf(szIconIndex, 10, "%u", iIconIndex);
ExtEscape(hdc, MFCOMMENT, strlen(szIconIndex)+1, szIconIndex, 0, NULL);
}
mfp.mm = MM_ISOTROPIC;
mfp.xExt = mfp.yExt = 0; /* FIXME ? */
mfp.hMF = CloseMetaFile(hdc);
if( !mfp.hMF )
return NULL;
hmem = GlobalAlloc( GMEM_MOVEABLE, sizeof(mfp) );
if( !hmem )
{
DeleteMetaFile(mfp.hMF);
return NULL;
}
mfdata = GlobalLock( hmem );
if( !mfdata )
{
GlobalFree( hmem );
DeleteMetaFile(mfp.hMF);
return NULL;
}
memcpy(mfdata,&mfp,sizeof(mfp));
GlobalUnlock( hmem );
TRACE("returning %p\n",hmem);
return hmem;
}