ole32: Convert the OpenDll list to a standard Wine list.
[wine] / dlls / ole32 / ole2_16.c
1
2 /*
3  *      OLE2 library - 16 bit only interfaces
4  *
5  *      Copyright 1995  Martin von Loewis
6  *      Copyright 1999  Francis Beaudet
7  *      Copyright 1999  Noel Borthwick
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #include "config.h"
25
26 #include <assert.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
31
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
34 #include "windef.h"
35 #include "winbase.h"
36 #include "wingdi.h"
37 #include "winuser.h"
38 #include "winnls.h"
39 #include "commctrl.h"
40 #include "ole2.h"
41 #include "ole2ver.h"
42 #include "winerror.h"
43 #include "wownt32.h"
44
45 #include "wine/winbase16.h"
46 #include "wine/wingdi16.h"
47 #include "wine/winuser16.h"
48 #include "ifs.h"
49
50 #include "wine/debug.h"
51
52 WINE_DEFAULT_DEBUG_CHANNEL(ole);
53
54 #define HICON_16(h32)           (LOWORD(h32))
55 #define HICON_32(h16)           ((HICON)(ULONG_PTR)(h16))
56 #define HINSTANCE_32(h16)       ((HINSTANCE)(ULONG_PTR)(h16))
57
58 /***********************************************************************
59  *           RegisterDragDrop (OLE2.35)
60  */
61 HRESULT WINAPI RegisterDragDrop16(
62         HWND16 hwnd,
63         LPDROPTARGET pDropTarget
64 ) {
65         FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
66         return S_OK;
67 }
68
69 /***********************************************************************
70  *           RevokeDragDrop (OLE2.36)
71  */
72 HRESULT WINAPI RevokeDragDrop16(
73         HWND16 hwnd
74 ) {
75         FIXME("(0x%04x),stub!\n",hwnd);
76         return S_OK;
77 }
78
79 /******************************************************************************
80  * OleMetaFilePictFromIconAndLabel (OLE2.56)
81  *
82  * Returns a global memory handle to a metafile which contains the icon and
83  * label given.
84  * I guess the result of that should look somehow like desktop icons.
85  * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
86  * This code might be wrong at some places.
87  */
88 HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16(
89         HICON16 hIcon,
90         LPCOLESTR16 lpszLabel,
91         LPCOLESTR16 lpszSourceFile,
92         UINT16 iIconIndex
93 ) {
94     METAFILEPICT16 *mf16;
95     HGLOBAL16 hmf16;
96     HMETAFILE hmf;
97     INT mfSize;
98     HDC hdc;
99
100     if (!hIcon) {
101         if (lpszSourceFile) {
102             HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
103
104             /* load the icon at index from lpszSourceFile */
105             hIcon = HICON_16(LoadIconA(HINSTANCE_32(hInstance), (LPCSTR)(DWORD)iIconIndex));
106             FreeLibrary16(hInstance);
107         } else
108             return 0;
109     }
110
111     FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n", 
112           hIcon, lpszLabel, lpszSourceFile, iIconIndex);
113
114     hdc = CreateMetaFileW(NULL);
115     DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */
116     TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */
117     hmf = CloseMetaFile(hdc);
118
119     hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
120     mf16 = (METAFILEPICT16 *)GlobalLock16(hmf16);
121     mf16->mm = MM_ANISOTROPIC;
122     mf16->xExt = 20; /* FIXME: bogus */
123     mf16->yExt = 20; /* ditto */
124     mfSize = GetMetaFileBitsEx(hmf, 0, 0);
125     mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize);
126     if(mf16->hMF)
127     {
128         GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF));
129         GlobalUnlock16(mf16->hMF);
130     }
131     return hmf16;
132 }
133
134
135 /******************************************************************************
136  *        CreateItemMoniker     (OLE2.27)
137  */
138 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR16 lpszItem,LPMONIKER* ppmk)
139 {
140     FIXME("(%s,%p),stub!\n",lpszDelim,ppmk);
141     *ppmk = NULL;
142     return E_NOTIMPL;
143 }
144
145
146 /******************************************************************************
147  *        CreateFileMoniker (OLE2.28)
148  */
149 HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk)
150 {
151     FIXME("(%s,%p),stub!\n",lpszPathName,ppmk);
152     return E_NOTIMPL;
153 }
154
155 /******************************************************************************
156  *        OleSetMenuDescriptor (OLE2.41)
157  *
158  * PARAMS
159  *  hOleMenu  FIXME: Should probably be an HOLEMENU16.
160  */
161 HRESULT WINAPI OleSetMenuDescriptor16(
162     HOLEMENU               hOleMenu,
163     HWND16                 hwndFrame,
164     HWND16                 hwndActiveObject,
165     LPOLEINPLACEFRAME        lpFrame,
166     LPOLEINPLACEACTIVEOBJECT lpActiveObject)
167 {
168     FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObject);
169     return E_NOTIMPL;
170 }
171
172 /******************************************************************************
173  *              IsValidInterface        [COMPOBJ.23]
174  *
175  * Determines whether a pointer is a valid interface.
176  *
177  * PARAMS
178  *  punk [I] Interface to be tested.
179  *
180  * RETURNS
181  *  TRUE, if the passed pointer is a valid interface, or FALSE otherwise.
182  */
183 BOOL WINAPI IsValidInterface16(SEGPTR punk)
184 {
185         DWORD **ptr;
186
187         if (IsBadReadPtr16(punk,4))
188                 return FALSE;
189         ptr = MapSL(punk);
190         if (IsBadReadPtr16((SEGPTR)ptr[0],4))   /* check vtable ptr */
191                 return FALSE;
192         ptr = MapSL((SEGPTR)ptr[0]);            /* ptr to first method */
193         if (IsBadReadPtr16((SEGPTR)ptr[0],2))
194                 return FALSE;
195         return TRUE;
196 }
197
198 /******************************************************************************
199  *              OleLoad        [OLE2.12]
200  *
201  * PARAMS
202  *  pStg Segmented LPSTORAGE pointer.
203  *  pClientSite Segmented LPOLECLIENTSITE pointer.
204  */
205 HRESULT WINAPI OleLoad16(
206     SEGPTR              pStg,
207     REFIID              riid,
208     SEGPTR              pClientSite,
209     LPVOID*             ppvObj)
210 {
211   FIXME("(%x,%s,%x,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
212   return E_NOTIMPL;
213 }
214
215 /******************************************************************************
216  *              OleDoAutoConvert        [OLE2.79]
217  */
218 HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
219 {
220     FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
221     return E_NOTIMPL;
222 }
223
224 /***********************************************************************
225  *           OleSetClipboard                            [OLE2.49]
226  */
227 HRESULT WINAPI OleSetClipboard16(IDataObject* pDataObj)
228 {
229   FIXME("(%p): stub\n", pDataObj);
230   return S_OK;
231 }
232
233 /***********************************************************************
234  *           OleGetClipboard                            [OLE2.50]
235  */
236 HRESULT WINAPI OleGetClipboard16(IDataObject** ppDataObj)
237 {
238   FIXME("(%p): stub\n", ppDataObj);
239   return E_NOTIMPL;
240 }
241
242 /***********************************************************************
243  *           OleFlushClipboard   [OLE2.76]
244  */
245
246 HRESULT WINAPI OleFlushClipboard16(void)
247 {
248   return OleFlushClipboard();
249 }