shdocvw: Always set hostui to NULL in SetClientsite.
[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
41 /**********************************************************************
42  * Shell Instance Objects
43  */
44 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid, 
45     REFIID riid, LPVOID *ppvClassObj);
46
47 /**********************************************************************
48  * WebBrowser declaration for SHDOCVW.DLL
49  */
50
51 typedef struct ConnectionPoint ConnectionPoint;
52
53 typedef struct {
54     const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
55
56     ConnectionPoint *wbe2;
57     ConnectionPoint *wbe;
58     ConnectionPoint *pns;
59
60     IUnknown *impl;
61 } ConnectionPointContainer;
62
63 typedef struct {
64     const IOleClientSiteVtbl      *lpOleClientSiteVtbl;
65     const IOleInPlaceSiteVtbl     *lpOleInPlaceSiteVtbl;
66     const IDocHostUIHandler2Vtbl  *lpDocHostUIHandlerVtbl;
67     const IOleDocumentSiteVtbl    *lpOleDocumentSiteVtbl;
68     const IOleCommandTargetVtbl   *lpOleCommandTargetVtbl;
69     const IDispatchVtbl           *lpDispatchVtbl;
70     const IServiceProviderVtbl    *lpServiceProviderVtbl;
71
72     /* Interfaces of InPlaceFrame object */
73     const IOleInPlaceFrameVtbl          *lpOleInPlaceFrameVtbl;
74
75     IDispatch *disp;
76
77     IUnknown *document;
78     IOleDocumentView *view;
79     IDocHostUIHandler *hostui;
80
81     HWND hwnd;
82     HWND frame_hwnd;
83
84     LPOLESTR url;
85
86     VARIANT_BOOL silent;
87     VARIANT_BOOL offline;
88
89     ConnectionPointContainer cps;
90 } DocHost;
91
92 struct WebBrowser {
93     /* Interfaces available via WebBrowser object */
94
95     const IWebBrowser2Vtbl              *lpWebBrowser2Vtbl;
96     const IOleObjectVtbl                *lpOleObjectVtbl;
97     const IOleInPlaceObjectVtbl         *lpOleInPlaceObjectVtbl;
98     const IOleControlVtbl               *lpOleControlVtbl;
99     const IPersistStorageVtbl           *lpPersistStorageVtbl;
100     const IPersistStreamInitVtbl        *lpPersistStreamInitVtbl;
101     const IProvideClassInfo2Vtbl        *lpProvideClassInfoVtbl;
102     const IViewObject2Vtbl              *lpViewObjectVtbl;
103     const IOleInPlaceActiveObjectVtbl   *lpOleInPlaceActiveObjectVtbl;
104     const IOleCommandTargetVtbl         *lpOleCommandTargetVtbl;
105     const IHlinkFrameVtbl               *lpHlinkFrameVtbl;
106
107     LONG ref;
108
109     INT version;
110
111     IOleClientSite *client;
112     IOleContainer *container;
113     IOleInPlaceSite *inplace;
114
115     /* window context */
116
117     HWND frame_hwnd;
118     IOleInPlaceFrame *frame;
119     IOleInPlaceUIWindow *uiwindow;
120     RECT pos_rect;
121     RECT clip_rect;
122     OLEINPLACEFRAMEINFO frameinfo;
123     SIZEL extent;
124
125     HWND shell_embedding_hwnd;
126
127     VARIANT_BOOL visible;
128     VARIANT_BOOL menu_bar;
129     VARIANT_BOOL address_bar;
130     VARIANT_BOOL status_bar;
131     VARIANT_BOOL tool_bar;
132
133     DocHost doc_host;
134 };
135
136 struct InternetExplorer {
137     const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
138
139     LONG ref;
140
141     HWND frame_hwnd;
142
143     DocHost doc_host;
144 };
145
146 #define WEBBROWSER(x)   ((IWebBrowser*)                 &(x)->lpWebBrowser2Vtbl)
147 #define WEBBROWSER2(x)  ((IWebBrowser2*)                &(x)->lpWebBrowser2Vtbl)
148 #define OLEOBJ(x)       ((IOleObject*)                  &(x)->lpOleObjectVtbl)
149 #define INPLACEOBJ(x)   ((IOleInPlaceObject*)           &(x)->lpOleInPlaceObjectVtbl)
150 #define CONTROL(x)      ((IOleControl*)                 &(x)->lpOleControlVtbl)
151 #define PERSTORAGE(x)   ((IPersistStorage*)             &(x)->lpPersistStorageVtbl)
152 #define PERSTRINIT(x)   ((IPersistStreamInit*)          &(x)->lpPersistStreamInitVtbl)
153 #define CLASSINFO(x)    ((IProvideClassInfo2*)          &(x)->lpProvideClassInfoVtbl)
154 #define CONPTCONT(x)    ((IConnectionPointContainer*)   &(x)->lpConnectionPointContainerVtbl)
155 #define VIEWOBJ(x)      ((IViewObject*)                 &(x)->lpViewObjectVtbl);
156 #define VIEWOBJ2(x)     ((IViewObject2*)                &(x)->lpViewObjectVtbl);
157 #define ACTIVEOBJ(x)    ((IOleInPlaceActiveObject*)     &(x)->lpOleInPlaceActiveObjectVtbl)
158 #define OLECMD(x)       ((IOleCommandTarget*)           &(x)->lpOleCommandTargetVtbl)
159 #define HLINKFRAME(x)   ((IHlinkFrame*)                 &(x)->lpHlinkFrameVtbl)
160
161 #define CLIENTSITE(x)   ((IOleClientSite*)              &(x)->lpOleClientSiteVtbl)
162 #define INPLACESITE(x)  ((IOleInPlaceSite*)             &(x)->lpOleInPlaceSiteVtbl)
163 #define DOCHOSTUI(x)    ((IDocHostUIHandler*)           &(x)->lpDocHostUIHandlerVtbl)
164 #define DOCHOSTUI2(x)   ((IDocHostUIHandler2*)          &(x)->lpDocHostUIHandlerVtbl)
165 #define DOCSITE(x)      ((IOleDocumentSite*)            &(x)->lpOleDocumentSiteVtbl)
166 #define CLDISP(x)       ((IDispatch*)                   &(x)->lpDispatchVtbl)
167 #define SERVPROV(x)     ((IServiceProvider*)            &(x)->lpServiceProviderVtbl)
168
169 #define INPLACEFRAME(x) ((IOleInPlaceFrame*)            &(x)->lpOleInPlaceFrameVtbl)
170
171 void WebBrowser_OleObject_Init(WebBrowser*);
172 void WebBrowser_ViewObject_Init(WebBrowser*);
173 void WebBrowser_Persist_Init(WebBrowser*);
174 void WebBrowser_ClassInfo_Init(WebBrowser*);
175 void WebBrowser_HlinkFrame_Init(WebBrowser*);
176
177 void WebBrowser_OleObject_Destroy(WebBrowser*);
178
179 void DocHost_Init(DocHost*,IDispatch*);
180 void DocHost_ClientSite_Init(DocHost*);
181 void DocHost_Frame_Init(DocHost*);
182
183 void DocHost_Release(DocHost*);
184 void DocHost_ClientSite_Release(DocHost*);
185
186 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
187 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
188
189 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
190 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
191
192 void create_doc_view_hwnd(DocHost*);
193 void deactivate_document(DocHost*);
194 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
195 HRESULT navigate_url(DocHost*,BSTR,VARIANT*,VARIANT*,VARIANT*,VARIANT*);
196
197 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
198 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
199
200 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
201
202 #define WB_WM_NAVIGATE2 (WM_USER+100)
203
204 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
205
206 /**********************************************************************
207  * Dll lifetime tracking declaration for shdocvw.dll
208  */
209 extern LONG SHDOCVW_refCount;
210 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
211 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
212
213 extern HINSTANCE shdocvw_hinstance;
214 extern void register_iewindow_class(void);
215 extern void unregister_iewindow_class(void);
216
217 HRESULT register_class_object(BOOL);
218 HRESULT get_typeinfo(ITypeInfo**);
219
220 /* memory allocation functions */
221
222 static inline void *shdocvw_alloc(size_t len)
223 {
224     return HeapAlloc(GetProcessHeap(), 0, len);
225 }
226
227 static inline void *shdocvw_realloc(void *mem, size_t len)
228 {
229     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
230 }
231
232 static inline BOOL shdocvw_free(void *mem)
233 {
234     return HeapFree(GetProcessHeap(), 0, mem);
235 }
236
237 #endif /* __WINE_SHDOCVW_H */