2 * Copyright 2005 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
26 static ATOM doc_view_atom = 0;
28 static void navigate_complete(WebBrowser *This)
30 IDispatch *disp, *docdisp = NULL;
31 DISPPARAMS dispparams;
36 hres = IOleClientSite_QueryInterface(This->client, &IID_IDispatch, (void**)&disp);
40 hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&docdisp);
42 FIXME("Could not get IDispatch interface\n");
45 dispparams.cNamedArgs = 0;
46 dispparams.rgdispidNamedArgs = NULL;
47 dispparams.rgvarg = params;
49 V_VT(params) = (VT_BYREF|VT_VARIANT);
50 V_BYREF(params) = &url;
52 V_VT(params+1) = VT_DISPATCH;
53 V_DISPATCH(params+1) = docdisp;
56 V_BSTR(&url) = This->url;
58 IDispatch_Invoke(disp, DISPID_NAVIGATECOMPLETE2, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
59 DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
60 IDispatch_Invoke(disp, DISPID_DOCUMENTCOMPLETE, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
61 DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
63 IDispatch_Release(disp);
65 IDispatch_Release(docdisp);
68 static LRESULT navigate2(WebBrowser *This)
73 TRACE("(%p)\n", This);
76 WARN("document == NULL\n");
80 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
82 FIXME("Could not get IHlinkTarget interface\n");
86 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
87 IHlinkTarget_Release(hlink);
89 FIXME("Navigate failed\n");
93 navigate_complete(This);
98 static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
102 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
104 if(msg == WM_CREATE) {
105 This = *(WebBrowser**)lParam;
106 ERR("create %p\n", This);
107 SetPropW(hwnd, wszTHIS, This);
109 This = GetPropW(hwnd, wszTHIS);
113 case WB_WM_NAVIGATE2:
114 return navigate2(This);
117 return DefWindowProcA(hwnd, msg, wParam, lParam);
120 void create_doc_view_hwnd(WebBrowser *This)
124 static const WCHAR wszShell_DocObject_View[] =
125 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
128 static WNDCLASSEXW wndclass = {
132 0, 0 /* native uses 4*/, NULL, NULL, NULL,
133 (HBRUSH)COLOR_WINDOWFRAME, NULL,
134 wszShell_DocObject_View,
138 wndclass.hInstance = shdocvw_hinstance;
140 doc_view_atom = RegisterClassExW(&wndclass);
143 GetWindowRect(This->shell_embedding_hwnd, &rect);
144 This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View,
145 wszShell_DocObject_View,
146 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
147 rect.left, rect.top, rect.right, rect.bottom, This->shell_embedding_hwnd,
148 NULL, shdocvw_hinstance, This);
151 #define DOCHOSTUI_THIS(iface) DEFINE_THIS(WebBrowser, DocHostUIHandler, iface)
153 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
154 REFIID riid, void **ppv)
156 WebBrowser *This = DOCHOSTUI_THIS(iface);
157 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
160 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
162 WebBrowser *This = DOCHOSTUI_THIS(iface);
163 return IOleClientSite_AddRef(CLIENTSITE(This));
166 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
168 WebBrowser *This = DOCHOSTUI_THIS(iface);
169 return IOleClientSite_Release(CLIENTSITE(This));
172 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
173 DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
175 WebBrowser *This = DOCHOSTUI_THIS(iface);
176 FIXME("(%p)->(%ld %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
180 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
181 DOCHOSTUIINFO *pInfo)
183 WebBrowser *This = DOCHOSTUI_THIS(iface);
184 IDocHostUIHandler *handler;
187 TRACE("(%p)->(%p)\n", This, pInfo);
190 hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler, (void**)&handler);
191 if(SUCCEEDED(hres)) {
192 hres = IDocHostUIHandler_GetHostInfo(handler, pInfo);
193 IDocHostUIHandler_Release(handler);
199 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
200 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
201 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
205 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
206 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
207 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
209 WebBrowser *This = DOCHOSTUI_THIS(iface);
210 FIXME("(%p)->(%ld %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
215 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
217 WebBrowser *This = DOCHOSTUI_THIS(iface);
218 FIXME("(%p)\n", This);
222 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
224 WebBrowser *This = DOCHOSTUI_THIS(iface);
225 FIXME("(%p)\n", This);
229 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
232 WebBrowser *This = DOCHOSTUI_THIS(iface);
233 FIXME("(%p)->(%x)\n", This, fEnable);
237 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
240 WebBrowser *This = DOCHOSTUI_THIS(iface);
241 FIXME("(%p)->(%x)\n", This, fActivate);
245 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
248 WebBrowser *This = DOCHOSTUI_THIS(iface);
249 FIXME("(%p)->(%x)\n", This, fActivate);
253 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
254 LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
256 WebBrowser *This = DOCHOSTUI_THIS(iface);
257 FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
261 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
262 LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
264 WebBrowser *This = DOCHOSTUI_THIS(iface);
265 FIXME("(%p)->(%p %p %ld)\n", This, lpMsg, pguidCmdGroup, nCmdID);
269 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
270 LPOLESTR *pchKey, DWORD dw)
272 WebBrowser *This = DOCHOSTUI_THIS(iface);
273 IDocHostUIHandler *handler;
276 TRACE("(%p)->(%p %ld)\n", This, pchKey, dw);
281 hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
283 if(SUCCEEDED(hres)) {
284 hres = IDocHostUIHandler_GetOptionKeyPath(handler, pchKey, dw);
285 IDocHostUIHandler_Release(handler);
292 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
293 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
295 WebBrowser *This = DOCHOSTUI_THIS(iface);
296 FIXME("(%p)\n", This);
300 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
301 IDispatch **ppDispatch)
303 WebBrowser *This = DOCHOSTUI_THIS(iface);
304 FIXME("(%p)->(%p)\n", This, ppDispatch);
308 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
309 DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
311 WebBrowser *This = DOCHOSTUI_THIS(iface);
312 FIXME("(%p)->(%ld %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
316 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
317 IDataObject *pDO, IDataObject **ppDORet)
319 WebBrowser *This = DOCHOSTUI_THIS(iface);
320 FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
324 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
325 LPOLESTR *pchKey, DWORD dw)
327 WebBrowser *This = DOCHOSTUI_THIS(iface);
328 IDocHostUIHandler2 *handler;
331 TRACE("(%p)->(%p %ld)\n", This, pchKey, dw);
336 hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler2,
338 if(SUCCEEDED(hres)) {
339 hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
340 IDocHostUIHandler2_Release(handler);
347 #undef DOCHOSTUI_THIS
349 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
350 DocHostUIHandler_QueryInterface,
351 DocHostUIHandler_AddRef,
352 DocHostUIHandler_Release,
353 DocHostUIHandler_ShowContextMenu,
354 DocHostUIHandler_GetHostInfo,
355 DocHostUIHandler_ShowUI,
356 DocHostUIHandler_HideUI,
357 DocHostUIHandler_UpdateUI,
358 DocHostUIHandler_EnableModeless,
359 DocHostUIHandler_OnDocWindowActivate,
360 DocHostUIHandler_OnFrameWindowActivate,
361 DocHostUIHandler_ResizeBorder,
362 DocHostUIHandler_TranslateAccelerator,
363 DocHostUIHandler_GetOptionKeyPath,
364 DocHostUIHandler_GetDropTarget,
365 DocHostUIHandler_GetExternal,
366 DocHostUIHandler_TranslateUrl,
367 DocHostUIHandler_FilterDataObject,
368 DocHostUIHandler_GetOverrideKeyPath
371 void WebBrowser_DocHost_Init(WebBrowser *This)
373 This->lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl;
375 This->doc_view_hwnd = NULL;