comctl32/tests: Make functions from test macros.
[wine] / dlls / shdocvw / shdocvw.h
1 /*
2  * Header includes for shdocvw.dll
3  *
4  * Copyright 2001 John R. Sheets (for CodeWeavers)
5  * Copyright 2005-2006 Jacek Caban for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #ifndef __WINE_SHDOCVW_H
23 #define __WINE_SHDOCVW_H
24
25 #define COBJMACROS
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33
34 #include "ole2.h"
35 #include "olectl.h"
36 #include "shlobj.h"
37 #include "exdisp.h"
38 #include "mshtmhst.h"
39 #include "hlink.h"
40 #include "htiframe.h"
41
42 #include "wine/unicode.h"
43 #include "wine/list.h"
44 #include "resource.h"
45
46
47 #define WM_UPDATEADDRBAR    (WM_APP+1)
48
49 /**********************************************************************
50  * Shell Instance Objects
51  */
52 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid, 
53     REFIID riid, LPVOID *ppvClassObj);
54
55 /**********************************************************************
56  * WebBrowser declaration for SHDOCVW.DLL
57  */
58
59 typedef struct ConnectionPoint ConnectionPoint;
60 typedef struct DocHost DocHost;
61
62 typedef struct {
63     IConnectionPointContainer IConnectionPointContainer_iface;
64
65     ConnectionPoint *wbe2;
66     ConnectionPoint *wbe;
67     ConnectionPoint *pns;
68
69     IUnknown *impl;
70 } ConnectionPointContainer;
71
72 typedef struct {
73     IHlinkFrame    IHlinkFrame_iface;
74     ITargetFrame2  ITargetFrame2_iface;
75
76     IUnknown *outer;
77     DocHost *doc_host;
78 } HlinkFrame;
79
80 struct _task_header_t;
81
82 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
83
84 typedef struct _task_header_t {
85     task_proc_t proc;
86 } task_header_t;
87
88 typedef struct _IDocHostContainerVtbl
89 {
90     ULONG (*addref)(DocHost*);
91     ULONG (*release)(DocHost*);
92     void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
93     HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
94     void (WINAPI* SetURL)(DocHost*,LPCWSTR);
95     HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
96 } IDocHostContainerVtbl;
97
98 struct DocHost {
99     IOleClientSite      IOleClientSite_iface;
100     IOleInPlaceSite     IOleInPlaceSite_iface;
101     IDocHostUIHandler2  IDocHostUIHandler2_iface;
102     IOleDocumentSite    IOleDocumentSite_iface;
103     IOleControlSite     IOleControlSite_iface;
104     IOleCommandTarget   IOleCommandTarget_iface;
105     IDispatch           IDispatch_iface;
106     IPropertyNotifySink IPropertyNotifySink_iface;
107     IServiceProvider    IServiceProvider_iface;
108
109     /* Interfaces of InPlaceFrame object */
110     IOleInPlaceFrame  IOleInPlaceFrame_iface;
111
112     IDispatch *disp;
113
114     IDispatch *client_disp;
115     IDocHostUIHandler *hostui;
116     IOleInPlaceFrame *frame;
117
118     IUnknown *document;
119     IOleDocumentView *view;
120     IUnknown *doc_navigate;
121
122     const IDocHostContainerVtbl *container_vtbl;
123
124     HWND hwnd;
125     HWND frame_hwnd;
126
127     LPOLESTR url;
128
129     VARIANT_BOOL silent;
130     VARIANT_BOOL offline;
131     VARIANT_BOOL busy;
132
133     READYSTATE ready_state;
134     READYSTATE doc_state;
135     DWORD prop_notif_cookie;
136     BOOL is_prop_notif;
137
138     ConnectionPointContainer cps;
139 };
140
141 struct WebBrowser {
142     IWebBrowser2             IWebBrowser2_iface;
143     IOleObject               IOleObject_iface;
144     IOleInPlaceObject        IOleInPlaceObject_iface;
145     IOleControl              IOleControl_iface;
146     IPersistStorage          IPersistStorage_iface;
147     IPersistMemory           IPersistMemory_iface;
148     IPersistStreamInit       IPersistStreamInit_iface;
149     IProvideClassInfo2       IProvideClassInfo2_iface;
150     IViewObject2             IViewObject2_iface;
151     IOleInPlaceActiveObject  IOleInPlaceActiveObject_iface;
152     IOleCommandTarget        IOleCommandTarget_iface;
153     IServiceProvider         IServiceProvider_iface;
154     IDataObject              IDataObject_iface;
155     HlinkFrame hlink_frame;
156
157     LONG ref;
158
159     INT version;
160
161     IOleClientSite *client;
162     IOleContainer *container;
163     IOleInPlaceSite *inplace;
164
165     /* window context */
166
167     HWND frame_hwnd;
168     IOleInPlaceUIWindow *uiwindow;
169     RECT pos_rect;
170     RECT clip_rect;
171     OLEINPLACEFRAMEINFO frameinfo;
172     SIZEL extent;
173
174     HWND shell_embedding_hwnd;
175
176     VARIANT_BOOL register_browser;
177     VARIANT_BOOL visible;
178     VARIANT_BOOL menu_bar;
179     VARIANT_BOOL address_bar;
180     VARIANT_BOOL status_bar;
181     VARIANT_BOOL tool_bar;
182     VARIANT_BOOL full_screen;
183     VARIANT_BOOL theater_mode;
184
185     DocHost doc_host;
186 };
187
188 typedef struct {
189     DocHost doc_host;
190
191     LONG ref;
192
193     InternetExplorer *ie;
194 } IEDocHost;
195
196 struct InternetExplorer {
197     IWebBrowser2 IWebBrowser2_iface;
198     HlinkFrame hlink_frame;
199
200     LONG ref;
201
202     HWND frame_hwnd;
203     HWND status_hwnd;
204     HMENU menu;
205     BOOL nohome;
206
207     struct list entry;
208     IEDocHost *doc_host;
209 };
210
211 void WebBrowser_OleObject_Init(WebBrowser*);
212 void WebBrowser_ViewObject_Init(WebBrowser*);
213 void WebBrowser_Persist_Init(WebBrowser*);
214 void WebBrowser_ClassInfo_Init(WebBrowser*);
215
216 void WebBrowser_OleObject_Destroy(WebBrowser*);
217
218 void DocHost_Init(DocHost*,IDispatch*,const IDocHostContainerVtbl*);
219 void DocHost_ClientSite_Init(DocHost*);
220 void DocHost_Frame_Init(DocHost*);
221 void release_dochost_client(DocHost*);
222
223 void DocHost_Release(DocHost*);
224 void DocHost_ClientSite_Release(DocHost*);
225
226 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
227 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
228
229 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*);
230 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**);
231
232 HRESULT ShellBrowser_Create(IShellBrowser**);
233 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
234 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
235
236 void create_doc_view_hwnd(DocHost*);
237 void deactivate_document(DocHost*);
238 HRESULT dochost_object_available(DocHost*,IUnknown*);
239 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
240 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
241 HRESULT go_home(DocHost*);
242 void set_doc_state(DocHost*,READYSTATE);
243 HRESULT get_location_url(DocHost*,BSTR*);
244 void handle_navigation_error(DocHost*,HRESULT,BSTR,IHTMLWindow2*);
245
246 #define WM_DOCHOSTTASK (WM_USER+0x300)
247 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,BOOL);
248 LRESULT  process_dochost_task(DocHost*,LPARAM);
249
250 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
251 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
252
253 void released_obj(void);
254
255 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
256
257 HRESULT InternetShortcut_Create(IUnknown*,REFIID,void**);
258
259 HRESULT TaskbarList_Create(IUnknown*,REFIID,void**);
260
261 /**********************************************************************
262  * Dll lifetime tracking declaration for shdocvw.dll
263  */
264 extern LONG SHDOCVW_refCount;
265 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
266 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
267
268 extern HINSTANCE shdocvw_hinstance;
269 extern void register_iewindow_class(void);
270 extern void unregister_iewindow_class(void);
271 extern HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR);
272
273 HRESULT register_class_object(BOOL);
274 HRESULT get_typeinfo(ITypeInfo**);
275 DWORD register_iexplore(BOOL);
276
277 const char *debugstr_variant(const VARIANT*);
278
279 /* memory allocation functions */
280
281 static inline void *heap_alloc(size_t len)
282 {
283     return HeapAlloc(GetProcessHeap(), 0, len);
284 }
285
286 static inline void *heap_alloc_zero(size_t len)
287 {
288     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
289 }
290
291 static inline void *heap_realloc(void *mem, size_t len)
292 {
293     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
294 }
295
296 static inline BOOL heap_free(void *mem)
297 {
298     return HeapFree(GetProcessHeap(), 0, mem);
299 }
300
301 static inline LPWSTR heap_strdupW(LPCWSTR str)
302 {
303     LPWSTR ret = NULL;
304
305     if(str) {
306         DWORD size;
307
308         size = (strlenW(str)+1)*sizeof(WCHAR);
309         ret = heap_alloc(size);
310         memcpy(ret, str, size);
311     }
312
313     return ret;
314 }
315
316 static inline LPWSTR co_strdupW(LPCWSTR str)
317 {
318     WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
319     if (ret)
320         lstrcpyW(ret, str);
321     return ret;
322 }
323
324 static inline LPWSTR co_strdupAtoW(LPCSTR str)
325 {
326     INT len;
327     WCHAR *ret;
328     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
329     ret = CoTaskMemAlloc(len*sizeof(WCHAR));
330     if (ret)
331         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
332     return ret;
333 }
334
335 static inline LPSTR co_strdupWtoA(LPCWSTR str)
336 {
337     INT len;
338     CHAR *ret;
339     len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
340     ret = CoTaskMemAlloc(len);
341     if (ret)
342         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
343     return ret;
344 }
345
346 #endif /* __WINE_SHDOCVW_H */