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
= NULL
;
31 DISPPARAMS dispparams
;
36 hres
= IUnknown_QueryInterface(This
->document
, &IID_IDispatch
, (void**)&disp
);
38 FIXME("Could not get IDispatch interface\n");
41 dispparams
.cNamedArgs
= 0;
42 dispparams
.rgdispidNamedArgs
= NULL
;
43 dispparams
.rgvarg
= params
;
45 V_VT(params
) = (VT_BYREF
|VT_VARIANT
);
46 V_BYREF(params
) = &url
;
48 V_VT(params
+1) = VT_DISPATCH
;
49 V_DISPATCH(params
+1) = disp
;
52 V_BSTR(&url
) = This
->url
;
54 call_sink(This
->cp_wbe2
, DISPID_NAVIGATECOMPLETE2
, &dispparams
);
55 call_sink(This
->cp_wbe2
, DISPID_DOCUMENTCOMPLETE
, &dispparams
);
58 IDispatch_Release(disp
);
61 static LRESULT
navigate2(WebBrowser
*This
)
66 TRACE("(%p)\n", This
);
69 WARN("document == NULL\n");
73 hres
= IUnknown_QueryInterface(This
->document
, &IID_IHlinkTarget
, (void**)&hlink
);
75 FIXME("Could not get IHlinkTarget interface\n");
79 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
80 IHlinkTarget_Release(hlink
);
82 FIXME("Navigate failed\n");
86 navigate_complete(This
);
91 static LRESULT
resize_document(WebBrowser
*This
, LONG width
, LONG height
)
93 RECT rect
= {0, 0, width
, height
};
95 TRACE("(%p)->(%ld %ld)\n", This
, width
, height
);
98 IOleDocumentView_SetRect(This
->view
, &rect
);
103 static LRESULT WINAPI
doc_view_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
107 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
109 if(msg
== WM_CREATE
) {
110 This
= *(WebBrowser
**)lParam
;
111 SetPropW(hwnd
, wszTHIS
, This
);
113 This
= GetPropW(hwnd
, wszTHIS
);
118 return resize_document(This
, LOWORD(lParam
), HIWORD(lParam
));
119 case WB_WM_NAVIGATE2
:
120 return navigate2(This
);
123 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
126 void create_doc_view_hwnd(WebBrowser
*This
)
130 static const WCHAR wszShell_DocObject_View
[] =
131 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
134 static WNDCLASSEXW wndclass
= {
138 0, 0 /* native uses 4*/, NULL
, NULL
, NULL
,
139 (HBRUSH
)COLOR_WINDOWFRAME
, NULL
,
140 wszShell_DocObject_View
,
144 wndclass
.hInstance
= shdocvw_hinstance
;
146 doc_view_atom
= RegisterClassExW(&wndclass
);
149 GetWindowRect(This
->shell_embedding_hwnd
, &rect
);
150 This
->doc_view_hwnd
= CreateWindowExW(0, wszShell_DocObject_View
,
151 wszShell_DocObject_View
,
152 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| WS_TABSTOP
| WS_MAXIMIZEBOX
,
153 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
, This
->shell_embedding_hwnd
,
154 NULL
, shdocvw_hinstance
, This
);
157 #define DOCHOSTUI_THIS(iface) DEFINE_THIS(WebBrowser, DocHostUIHandler, iface)
159 static HRESULT WINAPI
DocHostUIHandler_QueryInterface(IDocHostUIHandler2
*iface
,
160 REFIID riid
, void **ppv
)
162 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
163 return IOleClientSite_QueryInterface(CLIENTSITE(This
), riid
, ppv
);
166 static ULONG WINAPI
DocHostUIHandler_AddRef(IDocHostUIHandler2
*iface
)
168 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
169 return IOleClientSite_AddRef(CLIENTSITE(This
));
172 static ULONG WINAPI
DocHostUIHandler_Release(IDocHostUIHandler2
*iface
)
174 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
175 return IOleClientSite_Release(CLIENTSITE(This
));
178 static HRESULT WINAPI
DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2
*iface
,
179 DWORD dwID
, POINT
*ppt
, IUnknown
*pcmdtReserved
, IDispatch
*pdispReserved
)
181 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
182 FIXME("(%p)->(%ld %p %p %p)\n", This
, dwID
, ppt
, pcmdtReserved
, pdispReserved
);
186 static HRESULT WINAPI
DocHostUIHandler_GetHostInfo(IDocHostUIHandler2
*iface
,
187 DOCHOSTUIINFO
*pInfo
)
189 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
190 IDocHostUIHandler
*handler
;
193 TRACE("(%p)->(%p)\n", This
, pInfo
);
196 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
, (void**)&handler
);
197 if(SUCCEEDED(hres
)) {
198 hres
= IDocHostUIHandler_GetHostInfo(handler
, pInfo
);
199 IDocHostUIHandler_Release(handler
);
205 pInfo
->dwFlags
= DOCHOSTUIFLAG_DISABLE_HELP_MENU
| DOCHOSTUIFLAG_OPENNEWWIN
206 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8
| DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
207 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION
;
211 static HRESULT WINAPI
DocHostUIHandler_ShowUI(IDocHostUIHandler2
*iface
, DWORD dwID
,
212 IOleInPlaceActiveObject
*pActiveObject
, IOleCommandTarget
*pCommandTarget
,
213 IOleInPlaceFrame
*pFrame
, IOleInPlaceUIWindow
*pDoc
)
215 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
216 FIXME("(%p)->(%ld %p %p %p %p)\n", This
, dwID
, pActiveObject
, pCommandTarget
,
221 static HRESULT WINAPI
DocHostUIHandler_HideUI(IDocHostUIHandler2
*iface
)
223 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
224 FIXME("(%p)\n", This
);
228 static HRESULT WINAPI
DocHostUIHandler_UpdateUI(IDocHostUIHandler2
*iface
)
230 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
231 FIXME("(%p)\n", This
);
235 static HRESULT WINAPI
DocHostUIHandler_EnableModeless(IDocHostUIHandler2
*iface
,
238 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
239 FIXME("(%p)->(%x)\n", This
, fEnable
);
243 static HRESULT WINAPI
DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2
*iface
,
246 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
247 FIXME("(%p)->(%x)\n", This
, fActivate
);
251 static HRESULT WINAPI
DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2
*iface
,
254 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
255 FIXME("(%p)->(%x)\n", This
, fActivate
);
259 static HRESULT WINAPI
DocHostUIHandler_ResizeBorder(IDocHostUIHandler2
*iface
,
260 LPCRECT prcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fRameWindow
)
262 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
263 FIXME("(%p)->(%p %p %X)\n", This
, prcBorder
, pUIWindow
, fRameWindow
);
267 static HRESULT WINAPI
DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2
*iface
,
268 LPMSG lpMsg
, const GUID
*pguidCmdGroup
, DWORD nCmdID
)
270 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
271 FIXME("(%p)->(%p %p %ld)\n", This
, lpMsg
, pguidCmdGroup
, nCmdID
);
275 static HRESULT WINAPI
DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2
*iface
,
276 LPOLESTR
*pchKey
, DWORD dw
)
278 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
279 IDocHostUIHandler
*handler
;
282 TRACE("(%p)->(%p %ld)\n", This
, pchKey
, dw
);
287 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
,
289 if(SUCCEEDED(hres
)) {
290 hres
= IDocHostUIHandler_GetOptionKeyPath(handler
, pchKey
, dw
);
291 IDocHostUIHandler_Release(handler
);
298 static HRESULT WINAPI
DocHostUIHandler_GetDropTarget(IDocHostUIHandler2
*iface
,
299 IDropTarget
*pDropTarget
, IDropTarget
**ppDropTarget
)
301 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
302 FIXME("(%p)\n", This
);
306 static HRESULT WINAPI
DocHostUIHandler_GetExternal(IDocHostUIHandler2
*iface
,
307 IDispatch
**ppDispatch
)
309 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
310 FIXME("(%p)->(%p)\n", This
, ppDispatch
);
314 static HRESULT WINAPI
DocHostUIHandler_TranslateUrl(IDocHostUIHandler2
*iface
,
315 DWORD dwTranslate
, OLECHAR
*pchURLIn
, OLECHAR
**ppchURLOut
)
317 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
318 FIXME("(%p)->(%ld %s %p)\n", This
, dwTranslate
, debugstr_w(pchURLIn
), ppchURLOut
);
322 static HRESULT WINAPI
DocHostUIHandler_FilterDataObject(IDocHostUIHandler2
*iface
,
323 IDataObject
*pDO
, IDataObject
**ppDORet
)
325 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
326 FIXME("(%p)->(%p %p)\n", This
, pDO
, ppDORet
);
330 static HRESULT WINAPI
DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2
*iface
,
331 LPOLESTR
*pchKey
, DWORD dw
)
333 WebBrowser
*This
= DOCHOSTUI_THIS(iface
);
334 IDocHostUIHandler2
*handler
;
337 TRACE("(%p)->(%p %ld)\n", This
, pchKey
, dw
);
342 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler2
,
344 if(SUCCEEDED(hres
)) {
345 hres
= IDocHostUIHandler2_GetOverrideKeyPath(handler
, pchKey
, dw
);
346 IDocHostUIHandler2_Release(handler
);
353 #undef DOCHOSTUI_THIS
355 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl
= {
356 DocHostUIHandler_QueryInterface
,
357 DocHostUIHandler_AddRef
,
358 DocHostUIHandler_Release
,
359 DocHostUIHandler_ShowContextMenu
,
360 DocHostUIHandler_GetHostInfo
,
361 DocHostUIHandler_ShowUI
,
362 DocHostUIHandler_HideUI
,
363 DocHostUIHandler_UpdateUI
,
364 DocHostUIHandler_EnableModeless
,
365 DocHostUIHandler_OnDocWindowActivate
,
366 DocHostUIHandler_OnFrameWindowActivate
,
367 DocHostUIHandler_ResizeBorder
,
368 DocHostUIHandler_TranslateAccelerator
,
369 DocHostUIHandler_GetOptionKeyPath
,
370 DocHostUIHandler_GetDropTarget
,
371 DocHostUIHandler_GetExternal
,
372 DocHostUIHandler_TranslateUrl
,
373 DocHostUIHandler_FilterDataObject
,
374 DocHostUIHandler_GetOverrideKeyPath
377 void WebBrowser_DocHost_Init(WebBrowser
*This
)
379 This
->lpDocHostUIHandlerVtbl
= &DocHostUIHandler2Vtbl
;
381 This
->doc_view_hwnd
= NULL
;