2 * Implementation of IOleObject interfaces for WebBrowser control
8 * Copyright 2001 John R. Sheets (for CodeWeavers)
9 * Copyright 2005 Jacek Caban
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(ieframe
);
39 HWND WINAPI
SHSetParentHwnd(HWND hWnd
, HWND hWndParent
);
41 static ATOM shell_embedding_atom
= 0;
43 static LRESULT
resize_window(WebBrowser
*This
, LONG width
, LONG height
)
45 if(This
->doc_host
.hwnd
)
46 SetWindowPos(This
->doc_host
.hwnd
, NULL
, 0, 0, width
, height
,
47 SWP_NOZORDER
| SWP_NOACTIVATE
);
52 static void notify_on_focus(WebBrowser
*This
, BOOL got_focus
)
54 IOleControlSite
*control_site
;
60 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleControlSite
, (void**)&control_site
);
64 IOleControlSite_OnFocus(control_site
, got_focus
);
65 IOleControlSite_Release(control_site
);
68 static LRESULT WINAPI
shell_embedding_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
72 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
74 if(msg
== WM_CREATE
) {
75 This
= *(WebBrowser
**)lParam
;
76 SetPropW(hwnd
, wszTHIS
, This
);
78 This
= GetPropW(hwnd
, wszTHIS
);
83 return resize_window(This
, LOWORD(lParam
), HIWORD(lParam
));
85 return process_dochost_tasks(&This
->doc_host
);
87 notify_on_focus(This
, TRUE
);
90 notify_on_focus(This
, FALSE
);
94 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
97 static void create_shell_embedding_hwnd(WebBrowser
*This
)
99 IOleInPlaceSite
*inplace
;
103 static const WCHAR wszShellEmbedding
[] =
104 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
106 if(!shell_embedding_atom
) {
107 static WNDCLASSEXW wndclass
= {
110 shell_embedding_proc
,
111 0, 0 /* native uses 8 */, NULL
, NULL
, NULL
,
112 (HBRUSH
)(COLOR_WINDOW
+ 1), NULL
,
116 wndclass
.hInstance
= ieframe_instance
;
118 RegisterClassExW(&wndclass
);
121 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleInPlaceSite
, (void**)&inplace
);
122 if(SUCCEEDED(hres
)) {
123 IOleInPlaceSite_GetWindow(inplace
, &parent
);
124 IOleInPlaceSite_Release(inplace
);
127 This
->doc_host
.frame_hwnd
= This
->shell_embedding_hwnd
= CreateWindowExW(
129 wszShellEmbedding
, wszShellEmbedding
,
130 WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
131 | (parent
? WS_CHILD
| WS_TABSTOP
: WS_POPUP
| WS_MAXIMIZEBOX
),
133 NULL
, ieframe_instance
, This
);
135 TRACE("parent=%p hwnd=%p\n", parent
, This
->shell_embedding_hwnd
);
138 static HRESULT
activate_inplace(WebBrowser
*This
, IOleClientSite
*active_site
)
149 hres
= IOleClientSite_QueryInterface(active_site
, &IID_IOleInPlaceSite
,
150 (void**)&This
->inplace
);
152 WARN("Could not get IOleInPlaceSite\n");
156 hres
= IOleInPlaceSiteEx_CanInPlaceActivate(This
->inplace
);
158 WARN("CanInPlaceActivate returned: %08x\n", hres
);
159 IOleInPlaceSiteEx_Release(This
->inplace
);
160 This
->inplace
= NULL
;
164 hres
= IOleInPlaceSiteEx_GetWindow(This
->inplace
, &parent_hwnd
);
166 SHSetParentHwnd(This
->shell_embedding_hwnd
, parent_hwnd
);
168 IOleInPlaceSiteEx_OnInPlaceActivate(This
->inplace
);
170 This
->frameinfo
.cb
= sizeof(OLEINPLACEFRAMEINFO
);
171 IOleInPlaceSiteEx_GetWindowContext(This
->inplace
, &This
->doc_host
.frame
, &This
->uiwindow
,
172 &This
->pos_rect
, &This
->clip_rect
,
175 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
176 This
->pos_rect
.left
, This
->pos_rect
.top
,
177 This
->pos_rect
.right
-This
->pos_rect
.left
,
178 This
->pos_rect
.bottom
-This
->pos_rect
.top
,
179 SWP_NOZORDER
| SWP_SHOWWINDOW
);
182 IOleContainer
*container
;
184 IOleClientSite_ShowObject(This
->client
);
186 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
187 if(SUCCEEDED(hres
)) {
189 IOleContainer_Release(This
->container
);
190 This
->container
= container
;
194 if(This
->doc_host
.frame
)
195 IOleInPlaceFrame_GetWindow(This
->doc_host
.frame
, &This
->frame_hwnd
);
200 static HRESULT
activate_ui(WebBrowser
*This
, IOleClientSite
*active_site
)
204 static const WCHAR wszitem
[] = {'i','t','e','m',0};
208 if(This
->shell_embedding_hwnd
)
209 ShowWindow(This
->shell_embedding_hwnd
, SW_SHOW
);
213 hres
= activate_inplace(This
, active_site
);
217 IOleInPlaceSiteEx_OnUIActivate(This
->inplace
);
219 if(This
->doc_host
.frame
)
220 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
222 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
224 if(This
->doc_host
.frame
)
225 IOleInPlaceFrame_SetMenu(This
->doc_host
.frame
, NULL
, NULL
, This
->shell_embedding_hwnd
);
227 SetFocus(This
->shell_embedding_hwnd
);
228 notify_on_focus(This
, TRUE
);
233 static HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
235 IDispatch
*disp
= NULL
;
236 DISPPARAMS dispparams
= {NULL
, 0};
244 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
246 TRACE("Could not get IDispatch\n");
250 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
251 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, NULL
);
253 IDispatch_Release(disp
);
258 static HRESULT
on_offlineconnected_change(WebBrowser
*This
)
262 get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
264 if(V_VT(&offline
) == VT_BOOL
)
265 IWebBrowser2_put_Offline(&This
->IWebBrowser2_iface
, V_BOOL(&offline
));
266 else if(V_VT(&offline
) != VT_EMPTY
)
267 WARN("wrong V_VT(silent) %d\n", V_VT(&offline
));
272 static HRESULT
on_silent_change(WebBrowser
*This
)
276 get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
278 if(V_VT(&silent
) == VT_BOOL
)
279 IWebBrowser2_put_Silent(&This
->IWebBrowser2_iface
, V_BOOL(&silent
));
280 else if(V_VT(&silent
) != VT_EMPTY
)
281 WARN("wrong V_VT(silent) %d\n", V_VT(&silent
));
286 static void release_client_site(WebBrowser
*This
)
288 release_dochost_client(&This
->doc_host
);
291 IOleClientSite_Release(This
->client
);
295 if(This
->shell_embedding_hwnd
) {
296 DestroyWindow(This
->shell_embedding_hwnd
);
297 This
->shell_embedding_hwnd
= NULL
;
301 IOleInPlaceSiteEx_Release(This
->inplace
);
302 This
->inplace
= NULL
;
305 if(This
->container
) {
306 IOleContainer_Release(This
->container
);
307 This
->container
= NULL
;
311 IOleInPlaceUIWindow_Release(This
->uiwindow
);
312 This
->uiwindow
= NULL
;
316 IAdviseSink_Release(This
->sink
);
322 IEnumOLEVERB IEnumOLEVERB_iface
;
327 static inline EnumOLEVERB
*impl_from_IEnumOLEVERB(IEnumOLEVERB
*iface
)
329 return CONTAINING_RECORD(iface
, EnumOLEVERB
, IEnumOLEVERB_iface
);
332 static HRESULT WINAPI
EnumOLEVERB_QueryInterface(IEnumOLEVERB
*iface
, REFIID riid
, void **ppv
)
334 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
336 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
337 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
338 *ppv
= &This
->IEnumOLEVERB_iface
;
339 }else if(IsEqualGUID(&IID_IEnumOLEVERB
, riid
)) {
340 TRACE("(%p)->(IID_IEnumOLEVERB %p)\n", This
, ppv
);
341 *ppv
= &This
->IEnumOLEVERB_iface
;
343 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
345 return E_NOINTERFACE
;
348 IUnknown_AddRef((IUnknown
*)*ppv
);
352 static ULONG WINAPI
EnumOLEVERB_AddRef(IEnumOLEVERB
*iface
)
354 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
355 LONG ref
= InterlockedIncrement(&This
->ref
);
357 TRACE("(%p) ref=%d\n", This
, ref
);
362 static ULONG WINAPI
EnumOLEVERB_Release(IEnumOLEVERB
*iface
)
364 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
365 LONG ref
= InterlockedDecrement(&This
->ref
);
367 TRACE("(%p) ref=%d\n", This
, ref
);
375 static HRESULT WINAPI
EnumOLEVERB_Next(IEnumOLEVERB
*iface
, ULONG celt
, OLEVERB
*rgelt
, ULONG
*pceltFetched
)
377 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
379 static const OLEVERB verbs
[] =
380 {{OLEIVERB_PRIMARY
},{OLEIVERB_INPLACEACTIVATE
},{OLEIVERB_UIACTIVATE
},{OLEIVERB_SHOW
},{OLEIVERB_HIDE
}};
382 TRACE("(%p)->(%u %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
384 /* There are a few problems with this implementation, but that's how it seems to work in native. See tests. */
388 if(This
->iter
== sizeof(verbs
)/sizeof(*verbs
))
392 *rgelt
= verbs
[This
->iter
++];
396 static HRESULT WINAPI
EnumOLEVERB_Skip(IEnumOLEVERB
*iface
, ULONG celt
)
398 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
399 TRACE("(%p)->(%u)\n", This
, celt
);
403 static HRESULT WINAPI
EnumOLEVERB_Reset(IEnumOLEVERB
*iface
)
405 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
407 TRACE("(%p)\n", This
);
413 static HRESULT WINAPI
EnumOLEVERB_Clone(IEnumOLEVERB
*iface
, IEnumOLEVERB
**ppenum
)
415 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
416 FIXME("(%p)->(%p)\n", This
, ppenum
);
420 static const IEnumOLEVERBVtbl EnumOLEVERBVtbl
= {
421 EnumOLEVERB_QueryInterface
,
430 /**********************************************************************
431 * Implement the IOleObject interface for the WebBrowser control
434 static inline WebBrowser
*impl_from_IOleObject(IOleObject
*iface
)
436 return CONTAINING_RECORD(iface
, WebBrowser
, IOleObject_iface
);
439 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
441 WebBrowser
*This
= impl_from_IOleObject(iface
);
442 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
445 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
447 WebBrowser
*This
= impl_from_IOleObject(iface
);
448 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
451 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
453 WebBrowser
*This
= impl_from_IOleObject(iface
);
454 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
457 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, LPOLECLIENTSITE pClientSite
)
459 WebBrowser
*This
= impl_from_IOleObject(iface
);
460 IDocHostUIHandler
*hostui
;
461 IOleCommandTarget
*olecmd
;
462 IOleContainer
*container
;
466 TRACE("(%p)->(%p)\n", This
, pClientSite
);
468 if(This
->client
== pClientSite
)
471 release_client_site(This
);
474 on_commandstate_change(&This
->doc_host
, CSC_NAVIGATEBACK
, VARIANT_FALSE
);
475 on_commandstate_change(&This
->doc_host
, CSC_NAVIGATEFORWARD
, VARIANT_FALSE
);
477 if(This
->doc_host
.document
)
478 deactivate_document(&This
->doc_host
);
482 IOleClientSite_AddRef(pClientSite
);
483 This
->client
= pClientSite
;
485 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDispatch
,
488 This
->doc_host
.client_disp
= disp
;
490 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
,
493 This
->doc_host
.hostui
= hostui
;
495 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
496 if(SUCCEEDED(hres
)) {
497 ITargetContainer
*target_container
;
499 hres
= IOleContainer_QueryInterface(container
, &IID_ITargetContainer
,
500 (void**)&target_container
);
501 if(SUCCEEDED(hres
)) {
502 FIXME("Unsupported ITargetContainer\n");
503 ITargetContainer_Release(target_container
);
506 hres
= IOleContainer_QueryInterface(container
, &IID_IOleCommandTarget
, (void**)&olecmd
);
510 IOleContainer_Release(container
);
512 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
517 This
->doc_host
.olecmd
= olecmd
;
519 create_shell_embedding_hwnd(This
);
521 on_offlineconnected_change(This
);
522 on_silent_change(This
);
527 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, LPOLECLIENTSITE
*ppClientSite
)
529 WebBrowser
*This
= impl_from_IOleObject(iface
);
531 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
537 IOleClientSite_AddRef(This
->client
);
538 *ppClientSite
= This
->client
;
543 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
,
544 LPCOLESTR szContainerObj
)
546 WebBrowser
*This
= impl_from_IOleObject(iface
);
548 TRACE("(%p)->(%s, %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
550 /* We have nothing to do here. */
554 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
556 WebBrowser
*This
= impl_from_IOleObject(iface
);
558 TRACE("(%p)->(%d)\n", This
, dwSaveOption
);
560 if(dwSaveOption
!= OLECLOSE_NOSAVE
) {
561 FIXME("unimplemented flag: %x\n", dwSaveOption
);
565 if(This
->doc_host
.frame
)
566 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, NULL
, NULL
);
569 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, NULL
, NULL
);
572 IOleInPlaceSiteEx_OnUIDeactivate(This
->inplace
, FALSE
);
573 notify_on_focus(This
, FALSE
);
575 IOleInPlaceSiteEx_OnInPlaceDeactivate(This
->inplace
);
577 return IOleObject_SetClientSite(iface
, NULL
);
580 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
* pmk
)
582 WebBrowser
*This
= impl_from_IOleObject(iface
);
583 FIXME("(%p)->(%d, %p)\n", This
, dwWhichMoniker
, pmk
);
587 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
,
588 DWORD dwWhichMoniker
, LPMONIKER
*ppmk
)
590 WebBrowser
*This
= impl_from_IOleObject(iface
);
591 FIXME("(%p)->(%d, %d, %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
595 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, LPDATAOBJECT pDataObject
,
596 BOOL fCreation
, DWORD dwReserved
)
598 WebBrowser
*This
= impl_from_IOleObject(iface
);
599 FIXME("(%p)->(%p, %d, %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
603 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
,
604 LPDATAOBJECT
*ppDataObject
)
606 WebBrowser
*This
= impl_from_IOleObject(iface
);
607 FIXME("(%p)->(%d, %p)\n", This
, dwReserved
, ppDataObject
);
611 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, struct tagMSG
* lpmsg
,
612 LPOLECLIENTSITE pActiveSite
, LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
614 WebBrowser
*This
= impl_from_IOleObject(iface
);
616 TRACE("(%p)->(%d %p %p %d %p %s)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
,
617 wine_dbgstr_rect(lprcPosRect
));
622 TRACE("OLEIVERB_SHOW\n");
623 return activate_ui(This
, pActiveSite
);
624 case OLEIVERB_UIACTIVATE
:
625 TRACE("OLEIVERB_UIACTIVATE\n");
626 return activate_ui(This
, pActiveSite
);
627 case OLEIVERB_INPLACEACTIVATE
:
628 TRACE("OLEIVERB_INPLACEACTIVATE\n");
629 return activate_inplace(This
, pActiveSite
);
631 TRACE("OLEIVERB_HIDE\n");
633 IOleInPlaceSiteEx_OnInPlaceDeactivate(This
->inplace
);
634 if(This
->shell_embedding_hwnd
)
635 ShowWindow(This
->shell_embedding_hwnd
, SW_HIDE
);
638 FIXME("stub for %d\n", iVerb
);
645 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
647 WebBrowser
*This
= impl_from_IOleObject(iface
);
650 TRACE("(%p)->(%p)\n", This
, ppEnumOleVerb
);
652 ret
= heap_alloc(sizeof(*ret
));
654 return E_OUTOFMEMORY
;
656 ret
->IEnumOLEVERB_iface
.lpVtbl
= &EnumOLEVERBVtbl
;
660 *ppEnumOleVerb
= &ret
->IEnumOLEVERB_iface
;
664 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
666 WebBrowser
*This
= impl_from_IOleObject(iface
);
667 FIXME("(%p)\n", This
);
671 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
673 WebBrowser
*This
= impl_from_IOleObject(iface
);
674 FIXME("(%p)\n", This
);
678 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
* pClsid
)
680 WebBrowser
*This
= impl_from_IOleObject(iface
);
681 FIXME("(%p)->(%p)\n", This
, pClsid
);
685 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
,
686 LPOLESTR
* pszUserType
)
688 WebBrowser
*This
= impl_from_IOleObject(iface
);
689 TRACE("(%p, %d, %p)\n", This
, dwFormOfType
, pszUserType
);
690 return OleRegGetUserType(&CLSID_WebBrowser
, dwFormOfType
, pszUserType
);
693 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
695 WebBrowser
*This
= impl_from_IOleObject(iface
);
697 TRACE("(%p)->(%x %p)\n", This
, dwDrawAspect
, psizel
);
699 /* Tests show that dwDrawAspect is ignored */
700 This
->extent
= *psizel
;
704 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
706 WebBrowser
*This
= impl_from_IOleObject(iface
);
708 TRACE("(%p)->(%x, %p)\n", This
, dwDrawAspect
, psizel
);
710 /* Tests show that dwDrawAspect is ignored */
711 *psizel
= This
->extent
;
715 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
,
716 DWORD
* pdwConnection
)
718 WebBrowser
*This
= impl_from_IOleObject(iface
);
719 FIXME("(%p)->(%p, %p)\n", This
, pAdvSink
, pdwConnection
);
723 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
725 WebBrowser
*This
= impl_from_IOleObject(iface
);
726 FIXME("(%p)->(%d)\n", This
, dwConnection
);
730 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
732 WebBrowser
*This
= impl_from_IOleObject(iface
);
733 FIXME("(%p)->(%p)\n", This
, ppenumAdvise
);
737 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
739 WebBrowser
*This
= impl_from_IOleObject(iface
);
741 TRACE("(%p)->(%x, %p)\n", This
, dwAspect
, pdwStatus
);
743 *pdwStatus
= OLEMISC_SETCLIENTSITEFIRST
|OLEMISC_ACTIVATEWHENVISIBLE
|OLEMISC_INSIDEOUT
744 |OLEMISC_CANTLINKINSIDE
|OLEMISC_RECOMPOSEONRESIZE
;
749 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
* pLogpal
)
751 WebBrowser
*This
= impl_from_IOleObject(iface
);
752 FIXME("(%p)->(%p)\n", This
, pLogpal
);
756 static const IOleObjectVtbl OleObjectVtbl
=
758 OleObject_QueryInterface
,
761 OleObject_SetClientSite
,
762 OleObject_GetClientSite
,
763 OleObject_SetHostNames
,
765 OleObject_SetMoniker
,
766 OleObject_GetMoniker
,
767 OleObject_InitFromData
,
768 OleObject_GetClipboardData
,
772 OleObject_IsUpToDate
,
773 OleObject_GetUserClassID
,
774 OleObject_GetUserType
,
779 OleObject_EnumAdvise
,
780 OleObject_GetMiscStatus
,
781 OleObject_SetColorScheme
784 /**********************************************************************
785 * Implement the IOleInPlaceObject interface
788 static inline WebBrowser
*impl_from_IOleInPlaceObject(IOleInPlaceObject
*iface
)
790 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceObject_iface
);
793 static HRESULT WINAPI
OleInPlaceObject_QueryInterface(IOleInPlaceObject
*iface
,
794 REFIID riid
, LPVOID
*ppobj
)
796 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
797 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
800 static ULONG WINAPI
OleInPlaceObject_AddRef(IOleInPlaceObject
*iface
)
802 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
803 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
806 static ULONG WINAPI
OleInPlaceObject_Release(IOleInPlaceObject
*iface
)
808 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
809 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
812 static HRESULT WINAPI
OleInPlaceObject_GetWindow(IOleInPlaceObject
*iface
, HWND
* phwnd
)
814 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
816 TRACE("(%p)->(%p)\n", This
, phwnd
);
818 *phwnd
= This
->shell_embedding_hwnd
;
822 static HRESULT WINAPI
OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject
*iface
,
825 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
826 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
830 static HRESULT WINAPI
OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject
*iface
)
832 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
833 FIXME("(%p)\n", This
);
836 IOleInPlaceSiteEx_Release(This
->inplace
);
837 This
->inplace
= NULL
;
843 static HRESULT WINAPI
OleInPlaceObject_UIDeactivate(IOleInPlaceObject
*iface
)
845 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
846 FIXME("(%p)\n", This
);
850 static HRESULT WINAPI
OleInPlaceObject_SetObjectRects(IOleInPlaceObject
*iface
,
851 LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
853 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
855 TRACE("(%p)->(%s %s)\n", This
, wine_dbgstr_rect(lprcPosRect
), wine_dbgstr_rect(lprcClipRect
));
857 This
->pos_rect
= *lprcPosRect
;
860 This
->clip_rect
= *lprcClipRect
;
862 if(This
->shell_embedding_hwnd
) {
863 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
864 lprcPosRect
->left
, lprcPosRect
->top
,
865 lprcPosRect
->right
-lprcPosRect
->left
,
866 lprcPosRect
->bottom
-lprcPosRect
->top
,
867 SWP_NOZORDER
| SWP_NOACTIVATE
);
873 static HRESULT WINAPI
OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject
*iface
)
875 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
876 FIXME("(%p)\n", This
);
880 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl
=
882 OleInPlaceObject_QueryInterface
,
883 OleInPlaceObject_AddRef
,
884 OleInPlaceObject_Release
,
885 OleInPlaceObject_GetWindow
,
886 OleInPlaceObject_ContextSensitiveHelp
,
887 OleInPlaceObject_InPlaceDeactivate
,
888 OleInPlaceObject_UIDeactivate
,
889 OleInPlaceObject_SetObjectRects
,
890 OleInPlaceObject_ReactivateAndUndo
893 /**********************************************************************
894 * Implement the IOleControl interface
897 static inline WebBrowser
*impl_from_IOleControl(IOleControl
*iface
)
899 return CONTAINING_RECORD(iface
, WebBrowser
, IOleControl_iface
);
902 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
,
903 REFIID riid
, LPVOID
*ppobj
)
905 WebBrowser
*This
= impl_from_IOleControl(iface
);
906 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
909 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
911 WebBrowser
*This
= impl_from_IOleControl(iface
);
912 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
915 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
917 WebBrowser
*This
= impl_from_IOleControl(iface
);
918 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
921 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, LPCONTROLINFO pCI
)
923 WebBrowser
*This
= impl_from_IOleControl(iface
);
925 TRACE("(%p)->(%p)\n", This
, pCI
);
927 /* Tests show that this function should be not implemented */
931 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, struct tagMSG
*pMsg
)
933 WebBrowser
*This
= impl_from_IOleControl(iface
);
934 FIXME("(%p)->(%p)\n", This
, pMsg
);
938 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
940 WebBrowser
*This
= impl_from_IOleControl(iface
);
942 TRACE("(%p)->(%d)\n", This
, dispID
);
946 /* Unknown means multiple properties changed, so check them all.
947 * BUT the Webbrowser OleControl object doesn't appear to do this.
950 case DISPID_AMBIENT_DLCONTROL
:
952 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
953 return on_offlineconnected_change(This
);
954 case DISPID_AMBIENT_SILENT
:
955 return on_silent_change(This
);
958 FIXME("Unknown dispID %d\n", dispID
);
962 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
964 WebBrowser
*This
= impl_from_IOleControl(iface
);
965 FIXME("(%p)->(%x)\n", This
, bFreeze
);
969 static const IOleControlVtbl OleControlVtbl
=
971 OleControl_QueryInterface
,
974 OleControl_GetControlInfo
,
975 OleControl_OnMnemonic
,
976 OleControl_OnAmbientPropertyChange
,
977 OleControl_FreezeEvents
980 static inline WebBrowser
*impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject
*iface
)
982 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceActiveObject_iface
);
985 static HRESULT WINAPI
InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject
*iface
,
986 REFIID riid
, void **ppv
)
988 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
989 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
992 static ULONG WINAPI
InPlaceActiveObject_AddRef(IOleInPlaceActiveObject
*iface
)
994 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
995 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
998 static ULONG WINAPI
InPlaceActiveObject_Release(IOleInPlaceActiveObject
*iface
)
1000 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1001 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
1004 static HRESULT WINAPI
InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject
*iface
,
1007 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1008 return IOleInPlaceObject_GetWindow(&This
->IOleInPlaceObject_iface
, phwnd
);
1011 static HRESULT WINAPI
InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject
*iface
,
1014 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1015 return IOleInPlaceObject_ContextSensitiveHelp(&This
->IOleInPlaceObject_iface
, fEnterMode
);
1018 static HRESULT WINAPI
InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject
*iface
,
1021 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1022 IOleInPlaceActiveObject
*activeobj
;
1023 HRESULT hr
= S_FALSE
;
1025 TRACE("(%p)->(%p)\n", This
, lpmsg
);
1027 if(This
->doc_host
.document
) {
1028 if(SUCCEEDED(IUnknown_QueryInterface(This
->doc_host
.document
,
1029 &IID_IOleInPlaceActiveObject
,
1030 (void**)&activeobj
))) {
1031 hr
= IOleInPlaceActiveObject_TranslateAccelerator(activeobj
, lpmsg
);
1032 IOleInPlaceActiveObject_Release(activeobj
);
1042 static HRESULT WINAPI
InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject
*iface
,
1045 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1046 FIXME("(%p)->(%x)\n", This
, fActivate
);
1050 static HRESULT WINAPI
InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject
*iface
,
1053 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1054 FIXME("(%p)->(%x)\n", This
, fActivate
);
1058 static HRESULT WINAPI
InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject
*iface
,
1059 LPCRECT lprcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fFrameWindow
)
1061 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1062 FIXME("(%p)->(%p %p %x)\n", This
, lprcBorder
, pUIWindow
, fFrameWindow
);
1066 static HRESULT WINAPI
InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject
*iface
,
1069 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1070 FIXME("(%p)->(%x)\n", This
, fEnable
);
1074 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl
= {
1075 InPlaceActiveObject_QueryInterface
,
1076 InPlaceActiveObject_AddRef
,
1077 InPlaceActiveObject_Release
,
1078 InPlaceActiveObject_GetWindow
,
1079 InPlaceActiveObject_ContextSensitiveHelp
,
1080 InPlaceActiveObject_TranslateAccelerator
,
1081 InPlaceActiveObject_OnFrameWindowActivate
,
1082 InPlaceActiveObject_OnDocWindowActivate
,
1083 InPlaceActiveObject_ResizeBorder
,
1084 InPlaceActiveObject_EnableModeless
1087 static inline WebBrowser
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
1089 return CONTAINING_RECORD(iface
, WebBrowser
, IOleCommandTarget_iface
);
1092 static HRESULT WINAPI
WBOleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
1093 REFIID riid
, void **ppv
)
1095 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1096 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
1099 static ULONG WINAPI
WBOleCommandTarget_AddRef(IOleCommandTarget
*iface
)
1101 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1102 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
1105 static ULONG WINAPI
WBOleCommandTarget_Release(IOleCommandTarget
*iface
)
1107 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1108 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
1111 static HRESULT WINAPI
WBOleCommandTarget_QueryStatus(IOleCommandTarget
*iface
,
1112 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
1114 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1115 IOleCommandTarget
*cmdtrg
;
1118 TRACE("(%p)->(%s %u %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
,
1121 if(!This
->doc_host
.document
)
1124 /* NOTE: There are probably some commands that we should handle here
1125 * instead of forwarding to document object. */
1127 hres
= IUnknown_QueryInterface(This
->doc_host
.document
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1131 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
1132 IOleCommandTarget_Release(cmdtrg
);
1137 static HRESULT WINAPI
WBOleCommandTarget_Exec(IOleCommandTarget
*iface
,
1138 const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
,
1141 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1142 FIXME("(%p)->(%s %d %d %s %p)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
,
1143 nCmdexecopt
, debugstr_variant(pvaIn
), pvaOut
);
1147 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
1148 WBOleCommandTarget_QueryInterface
,
1149 WBOleCommandTarget_AddRef
,
1150 WBOleCommandTarget_Release
,
1151 WBOleCommandTarget_QueryStatus
,
1152 WBOleCommandTarget_Exec
1155 void WebBrowser_OleObject_Init(WebBrowser
*This
)
1161 /* default aspect ratio is 96dpi / 96dpi */
1163 dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
1164 dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
1167 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1168 This
->IOleInPlaceObject_iface
.lpVtbl
= &OleInPlaceObjectVtbl
;
1169 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1170 This
->IOleInPlaceActiveObject_iface
.lpVtbl
= &OleInPlaceActiveObjectVtbl
;
1171 This
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
1173 /* Default size is 50x20 pixels, in himetric units */
1174 This
->extent
.cx
= MulDiv( 50, 2540, dpi_x
);
1175 This
->extent
.cy
= MulDiv( 20, 2540, dpi_y
);
1178 void WebBrowser_OleObject_Destroy(WebBrowser
*This
)
1180 release_client_site(This
);