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: %08lx\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 if(This
->ui_activated
)
220 IOleInPlaceSiteEx_OnUIActivate(This
->inplace
);
222 if(This
->doc_host
.frame
)
223 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
225 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
227 if(This
->doc_host
.frame
)
228 IOleInPlaceFrame_SetMenu(This
->doc_host
.frame
, NULL
, NULL
, This
->shell_embedding_hwnd
);
230 SetFocus(This
->shell_embedding_hwnd
);
231 notify_on_focus(This
, TRUE
);
233 activate_document(&This
->doc_host
);
235 This
->ui_activated
= TRUE
;
240 static HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
242 IDispatch
*disp
= NULL
;
243 DISPPARAMS dispparams
= {NULL
, 0};
251 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
253 TRACE("Could not get IDispatch\n");
257 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
258 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, NULL
);
260 IDispatch_Release(disp
);
265 static HRESULT
on_offlineconnected_change(WebBrowser
*This
)
269 get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
271 if(V_VT(&offline
) == VT_BOOL
)
272 IWebBrowser2_put_Offline(&This
->IWebBrowser2_iface
, V_BOOL(&offline
));
273 else if(V_VT(&offline
) != VT_EMPTY
)
274 WARN("wrong V_VT(silent) %d\n", V_VT(&offline
));
279 static HRESULT
on_silent_change(WebBrowser
*This
)
283 get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
285 if(V_VT(&silent
) == VT_BOOL
)
286 IWebBrowser2_put_Silent(&This
->IWebBrowser2_iface
, V_BOOL(&silent
));
287 else if(V_VT(&silent
) != VT_EMPTY
)
288 WARN("wrong V_VT(silent) %d\n", V_VT(&silent
));
293 static void release_client_site(WebBrowser
*This
, BOOL destroy_win
)
295 release_dochost_client(&This
->doc_host
);
298 IOleClientSite_Release(This
->client
);
302 if(This
->client_closed
) {
303 IOleClientSite_Release(This
->client_closed
);
304 This
->client_closed
= NULL
;
307 if(destroy_win
&& This
->shell_embedding_hwnd
) {
308 DestroyWindow(This
->shell_embedding_hwnd
);
309 This
->shell_embedding_hwnd
= NULL
;
313 IOleInPlaceSiteEx_Release(This
->inplace
);
314 This
->inplace
= NULL
;
317 if(This
->container
) {
318 IOleContainer_Release(This
->container
);
319 This
->container
= NULL
;
323 IOleInPlaceUIWindow_Release(This
->uiwindow
);
324 This
->uiwindow
= NULL
;
329 IEnumOLEVERB IEnumOLEVERB_iface
;
334 static inline EnumOLEVERB
*impl_from_IEnumOLEVERB(IEnumOLEVERB
*iface
)
336 return CONTAINING_RECORD(iface
, EnumOLEVERB
, IEnumOLEVERB_iface
);
339 static HRESULT WINAPI
EnumOLEVERB_QueryInterface(IEnumOLEVERB
*iface
, REFIID riid
, void **ppv
)
341 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
343 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
344 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
345 *ppv
= &This
->IEnumOLEVERB_iface
;
346 }else if(IsEqualGUID(&IID_IEnumOLEVERB
, riid
)) {
347 TRACE("(%p)->(IID_IEnumOLEVERB %p)\n", This
, ppv
);
348 *ppv
= &This
->IEnumOLEVERB_iface
;
350 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
352 return E_NOINTERFACE
;
355 IUnknown_AddRef((IUnknown
*)*ppv
);
359 static ULONG WINAPI
EnumOLEVERB_AddRef(IEnumOLEVERB
*iface
)
361 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
362 LONG ref
= InterlockedIncrement(&This
->ref
);
364 TRACE("(%p) ref=%ld\n", This
, ref
);
369 static ULONG WINAPI
EnumOLEVERB_Release(IEnumOLEVERB
*iface
)
371 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
372 LONG ref
= InterlockedDecrement(&This
->ref
);
374 TRACE("(%p) ref=%ld\n", This
, ref
);
382 static HRESULT WINAPI
EnumOLEVERB_Next(IEnumOLEVERB
*iface
, ULONG celt
, OLEVERB
*rgelt
, ULONG
*pceltFetched
)
384 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
386 static const OLEVERB verbs
[] =
387 {{OLEIVERB_PRIMARY
},{OLEIVERB_INPLACEACTIVATE
},{OLEIVERB_UIACTIVATE
},{OLEIVERB_SHOW
},{OLEIVERB_HIDE
}};
389 TRACE("(%p)->(%lu %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
391 /* There are a few problems with this implementation, but that's how it seems to work in native. See tests. */
395 if(This
->iter
== ARRAY_SIZE(verbs
))
399 *rgelt
= verbs
[This
->iter
++];
403 static HRESULT WINAPI
EnumOLEVERB_Skip(IEnumOLEVERB
*iface
, ULONG celt
)
405 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
406 TRACE("(%p)->(%lu)\n", This
, celt
);
410 static HRESULT WINAPI
EnumOLEVERB_Reset(IEnumOLEVERB
*iface
)
412 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
414 TRACE("(%p)\n", This
);
420 static HRESULT WINAPI
EnumOLEVERB_Clone(IEnumOLEVERB
*iface
, IEnumOLEVERB
**ppenum
)
422 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
423 FIXME("(%p)->(%p)\n", This
, ppenum
);
427 static const IEnumOLEVERBVtbl EnumOLEVERBVtbl
= {
428 EnumOLEVERB_QueryInterface
,
437 /**********************************************************************
438 * Implement the IOleObject interface for the WebBrowser control
441 static inline WebBrowser
*impl_from_IOleObject(IOleObject
*iface
)
443 return CONTAINING_RECORD(iface
, WebBrowser
, IOleObject_iface
);
446 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
448 WebBrowser
*This
= impl_from_IOleObject(iface
);
449 return IUnknown_QueryInterface(This
->hlink_frame
.outer
, riid
, ppv
);
452 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
454 WebBrowser
*This
= impl_from_IOleObject(iface
);
455 return IUnknown_AddRef(This
->hlink_frame
.outer
);
458 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
460 WebBrowser
*This
= impl_from_IOleObject(iface
);
461 return IUnknown_Release(This
->hlink_frame
.outer
);
464 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, LPOLECLIENTSITE pClientSite
)
466 WebBrowser
*This
= impl_from_IOleObject(iface
);
467 IDocHostUIHandler
*hostui
;
468 IOleCommandTarget
*olecmd
;
469 BOOL get_olecmd
= TRUE
;
470 IOleContainer
*container
;
474 TRACE("(%p)->(%p)\n", This
, pClientSite
);
476 if(This
->client_closed
) {
477 IOleClientSite_Release(This
->client_closed
);
478 This
->client_closed
= NULL
;
481 if(This
->client
== pClientSite
)
484 if(This
->client
&& pClientSite
) {
486 olecmd
= This
->doc_host
.olecmd
;
488 IOleCommandTarget_AddRef(olecmd
);
491 release_client_site(This
, !pClientSite
);
494 on_commandstate_change(&This
->doc_host
, CSC_NAVIGATEBACK
, FALSE
);
495 on_commandstate_change(&This
->doc_host
, CSC_NAVIGATEFORWARD
, FALSE
);
497 if(This
->doc_host
.document
)
498 deactivate_document(&This
->doc_host
);
502 IOleClientSite_AddRef(pClientSite
);
503 This
->client
= pClientSite
;
505 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDispatch
,
508 This
->doc_host
.client_disp
= disp
;
510 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
,
513 This
->doc_host
.hostui
= hostui
;
516 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
517 if(SUCCEEDED(hres
)) {
518 ITargetContainer
*target_container
;
520 hres
= IOleContainer_QueryInterface(container
, &IID_ITargetContainer
,
521 (void**)&target_container
);
522 if(SUCCEEDED(hres
)) {
523 FIXME("Unsupported ITargetContainer\n");
524 ITargetContainer_Release(target_container
);
527 hres
= IOleContainer_QueryInterface(container
, &IID_IOleCommandTarget
, (void**)&olecmd
);
531 IOleContainer_Release(container
);
533 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
539 This
->doc_host
.olecmd
= olecmd
;
541 if(This
->shell_embedding_hwnd
) {
542 IOleInPlaceSite
*inplace
;
545 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleInPlaceSite
, (void**)&inplace
);
546 if(SUCCEEDED(hres
)) {
547 hres
= IOleInPlaceSite_GetWindow(inplace
, &parent
);
548 IOleInPlaceSite_Release(inplace
);
550 SHSetParentHwnd(This
->shell_embedding_hwnd
, parent
);
553 create_shell_embedding_hwnd(This
);
556 on_offlineconnected_change(This
);
557 on_silent_change(This
);
558 SetQueryNetSessionCount(SESSION_INCREMENT
);
563 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, LPOLECLIENTSITE
*ppClientSite
)
565 WebBrowser
*This
= impl_from_IOleObject(iface
);
567 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
573 IOleClientSite_AddRef(This
->client
);
574 *ppClientSite
= This
->client
;
579 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
,
580 LPCOLESTR szContainerObj
)
582 WebBrowser
*This
= impl_from_IOleObject(iface
);
584 TRACE("(%p)->(%s, %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
586 /* We have nothing to do here. */
590 static void deactivate_ui(WebBrowser
*This
)
592 if(This
->ui_activated
) {
593 if(This
->doc_host
.frame
)
594 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, NULL
, NULL
);
597 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, NULL
, NULL
);
600 IOleInPlaceSiteEx_OnUIDeactivate(This
->inplace
, FALSE
);
601 notify_on_focus(This
, FALSE
);
603 This
->ui_activated
= FALSE
;
607 IOleInPlaceSiteEx_OnInPlaceDeactivate(This
->inplace
);
610 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
612 WebBrowser
*This
= impl_from_IOleObject(iface
);
613 IOleClientSite
*client
;
616 TRACE("(%p)->(%ld)\n", This
, dwSaveOption
);
618 if(dwSaveOption
!= OLECLOSE_NOSAVE
) {
619 FIXME("unimplemented flag: %lx\n", dwSaveOption
);
625 /* store old client site - we need to restore it in DoVerb */
626 client
= This
->client
;
628 IOleClientSite_AddRef(This
->client
);
629 hres
= IOleObject_SetClientSite(iface
, NULL
);
630 This
->client_closed
= client
;
632 if(This
->advise_holder
)
633 IOleAdviseHolder_SendOnClose(This
->advise_holder
);
638 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
* pmk
)
640 WebBrowser
*This
= impl_from_IOleObject(iface
);
641 FIXME("(%p)->(%ld, %p)\n", This
, dwWhichMoniker
, pmk
);
645 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
,
646 DWORD dwWhichMoniker
, LPMONIKER
*ppmk
)
648 WebBrowser
*This
= impl_from_IOleObject(iface
);
649 FIXME("(%p)->(%ld, %ld, %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
653 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, LPDATAOBJECT pDataObject
,
654 BOOL fCreation
, DWORD dwReserved
)
656 WebBrowser
*This
= impl_from_IOleObject(iface
);
657 FIXME("(%p)->(%p, %d, %ld)\n", This
, pDataObject
, fCreation
, dwReserved
);
661 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
,
662 LPDATAOBJECT
*ppDataObject
)
664 WebBrowser
*This
= impl_from_IOleObject(iface
);
665 FIXME("(%p)->(%ld, %p)\n", This
, dwReserved
, ppDataObject
);
669 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, struct tagMSG
* lpmsg
,
670 LPOLECLIENTSITE pActiveSite
, LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
672 WebBrowser
*This
= impl_from_IOleObject(iface
);
674 TRACE("(%p)->(%ld %p %p %ld %p %s)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
,
675 wine_dbgstr_rect(lprcPosRect
));
677 /* restore closed client site if we have one */
678 if(!This
->client
&& This
->client_closed
) {
679 IOleClientSite
*client
= This
->client_closed
;
680 This
->client_closed
= NULL
;
681 IOleObject_SetClientSite(iface
, client
);
682 IOleClientSite_Release(client
);
688 TRACE("OLEIVERB_SHOW\n");
689 return activate_ui(This
, pActiveSite
);
690 case OLEIVERB_UIACTIVATE
:
691 TRACE("OLEIVERB_UIACTIVATE\n");
692 return activate_ui(This
, pActiveSite
);
693 case OLEIVERB_INPLACEACTIVATE
:
694 TRACE("OLEIVERB_INPLACEACTIVATE\n");
695 return activate_inplace(This
, pActiveSite
);
697 TRACE("OLEIVERB_HIDE\n");
700 IOleInPlaceSiteEx_Release(This
->inplace
);
701 This
->inplace
= NULL
;
703 if(This
->shell_embedding_hwnd
)
704 ShowWindow(This
->shell_embedding_hwnd
, SW_HIDE
);
707 FIXME("stub for %ld\n", iVerb
);
714 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
716 WebBrowser
*This
= impl_from_IOleObject(iface
);
719 TRACE("(%p)->(%p)\n", This
, ppEnumOleVerb
);
721 ret
= malloc(sizeof(*ret
));
723 return E_OUTOFMEMORY
;
725 ret
->IEnumOLEVERB_iface
.lpVtbl
= &EnumOLEVERBVtbl
;
729 *ppEnumOleVerb
= &ret
->IEnumOLEVERB_iface
;
733 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
735 WebBrowser
*This
= impl_from_IOleObject(iface
);
736 FIXME("(%p)\n", This
);
740 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
742 WebBrowser
*This
= impl_from_IOleObject(iface
);
743 FIXME("(%p)\n", This
);
747 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
*pClsid
)
749 WebBrowser
*This
= impl_from_IOleObject(iface
);
751 TRACE("(%p)->(%p)\n", This
, pClsid
);
753 *pClsid
= This
->version
== 1 ? CLSID_WebBrowser_V1
: CLSID_WebBrowser
;
757 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
,
758 LPOLESTR
* pszUserType
)
760 WebBrowser
*This
= impl_from_IOleObject(iface
);
761 TRACE("(%p, %ld, %p)\n", This
, dwFormOfType
, pszUserType
);
762 return OleRegGetUserType(&CLSID_WebBrowser
, dwFormOfType
, pszUserType
);
765 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
767 WebBrowser
*This
= impl_from_IOleObject(iface
);
769 TRACE("(%p)->(%lx %p)\n", This
, dwDrawAspect
, psizel
);
771 /* Tests show that dwDrawAspect is ignored */
772 This
->extent
= *psizel
;
776 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
778 WebBrowser
*This
= impl_from_IOleObject(iface
);
780 TRACE("(%p)->(%lx, %p)\n", This
, dwDrawAspect
, psizel
);
782 /* Tests show that dwDrawAspect is ignored */
783 *psizel
= This
->extent
;
787 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
,
788 DWORD
*pdwConnection
)
790 WebBrowser
*This
= impl_from_IOleObject(iface
);
793 TRACE("(%p)->(%p, %p)\n", This
, pAdvSink
, pdwConnection
);
803 if(!This
->advise_holder
)
804 hr
= CreateOleAdviseHolder(&This
->advise_holder
);
807 hr
= IOleAdviseHolder_Advise(This
->advise_holder
, pAdvSink
, pdwConnection
);
812 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
814 WebBrowser
*This
= impl_from_IOleObject(iface
);
816 TRACE("(%p)->(%ld)\n", This
, dwConnection
);
818 if(!This
->advise_holder
)
819 return OLE_E_NOCONNECTION
;
821 return IOleAdviseHolder_Unadvise(This
->advise_holder
, dwConnection
);
824 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
826 WebBrowser
*This
= impl_from_IOleObject(iface
);
828 TRACE("(%p)->(%p): returning E_NOTIMPL\n", This
, ppenumAdvise
);
830 *ppenumAdvise
= NULL
;
834 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
836 WebBrowser
*This
= impl_from_IOleObject(iface
);
838 TRACE("(%p)->(%lx, %p)\n", This
, dwAspect
, pdwStatus
);
840 *pdwStatus
= OLEMISC_SETCLIENTSITEFIRST
|OLEMISC_ACTIVATEWHENVISIBLE
|OLEMISC_INSIDEOUT
841 |OLEMISC_CANTLINKINSIDE
|OLEMISC_RECOMPOSEONRESIZE
;
846 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
* pLogpal
)
848 WebBrowser
*This
= impl_from_IOleObject(iface
);
849 FIXME("(%p)->(%p)\n", This
, pLogpal
);
853 static const IOleObjectVtbl OleObjectVtbl
=
855 OleObject_QueryInterface
,
858 OleObject_SetClientSite
,
859 OleObject_GetClientSite
,
860 OleObject_SetHostNames
,
862 OleObject_SetMoniker
,
863 OleObject_GetMoniker
,
864 OleObject_InitFromData
,
865 OleObject_GetClipboardData
,
869 OleObject_IsUpToDate
,
870 OleObject_GetUserClassID
,
871 OleObject_GetUserType
,
876 OleObject_EnumAdvise
,
877 OleObject_GetMiscStatus
,
878 OleObject_SetColorScheme
881 /**********************************************************************
882 * Implement the IOleInPlaceObject interface
885 static inline WebBrowser
*impl_from_IOleInPlaceObject(IOleInPlaceObject
*iface
)
887 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceObject_iface
);
890 static HRESULT WINAPI
OleInPlaceObject_QueryInterface(IOleInPlaceObject
*iface
,
891 REFIID riid
, LPVOID
*ppobj
)
893 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
894 return IUnknown_QueryInterface(This
->hlink_frame
.outer
, riid
, ppobj
);
897 static ULONG WINAPI
OleInPlaceObject_AddRef(IOleInPlaceObject
*iface
)
899 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
900 return IUnknown_AddRef(This
->hlink_frame
.outer
);
903 static ULONG WINAPI
OleInPlaceObject_Release(IOleInPlaceObject
*iface
)
905 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
906 return IUnknown_Release(This
->hlink_frame
.outer
);
909 static HRESULT WINAPI
OleInPlaceObject_GetWindow(IOleInPlaceObject
*iface
, HWND
* phwnd
)
911 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
913 TRACE("(%p)->(%p)\n", This
, phwnd
);
915 *phwnd
= This
->shell_embedding_hwnd
;
919 static HRESULT WINAPI
OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject
*iface
,
922 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
923 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
927 static HRESULT WINAPI
OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject
*iface
)
929 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
930 FIXME("(%p)\n", This
);
933 IOleInPlaceSiteEx_Release(This
->inplace
);
934 This
->inplace
= NULL
;
940 static HRESULT WINAPI
OleInPlaceObject_UIDeactivate(IOleInPlaceObject
*iface
)
942 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
943 FIXME("(%p)\n", This
);
947 static HRESULT WINAPI
OleInPlaceObject_SetObjectRects(IOleInPlaceObject
*iface
,
948 LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
950 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
952 TRACE("(%p)->(%s %s)\n", This
, wine_dbgstr_rect(lprcPosRect
), wine_dbgstr_rect(lprcClipRect
));
954 This
->pos_rect
= *lprcPosRect
;
957 This
->clip_rect
= *lprcClipRect
;
959 if(This
->shell_embedding_hwnd
) {
960 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
961 lprcPosRect
->left
, lprcPosRect
->top
,
962 lprcPosRect
->right
-lprcPosRect
->left
,
963 lprcPosRect
->bottom
-lprcPosRect
->top
,
964 SWP_NOZORDER
| SWP_NOACTIVATE
);
970 static HRESULT WINAPI
OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject
*iface
)
972 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
973 FIXME("(%p)\n", This
);
977 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl
=
979 OleInPlaceObject_QueryInterface
,
980 OleInPlaceObject_AddRef
,
981 OleInPlaceObject_Release
,
982 OleInPlaceObject_GetWindow
,
983 OleInPlaceObject_ContextSensitiveHelp
,
984 OleInPlaceObject_InPlaceDeactivate
,
985 OleInPlaceObject_UIDeactivate
,
986 OleInPlaceObject_SetObjectRects
,
987 OleInPlaceObject_ReactivateAndUndo
990 /**********************************************************************
991 * Implement the IOleControl interface
994 static inline WebBrowser
*impl_from_IOleControl(IOleControl
*iface
)
996 return CONTAINING_RECORD(iface
, WebBrowser
, IOleControl_iface
);
999 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
,
1000 REFIID riid
, LPVOID
*ppobj
)
1002 WebBrowser
*This
= impl_from_IOleControl(iface
);
1003 return IUnknown_QueryInterface(This
->hlink_frame
.outer
, riid
, ppobj
);
1006 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
1008 WebBrowser
*This
= impl_from_IOleControl(iface
);
1009 return IUnknown_AddRef(This
->hlink_frame
.outer
);
1012 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
1014 WebBrowser
*This
= impl_from_IOleControl(iface
);
1015 return IUnknown_Release(This
->hlink_frame
.outer
);
1018 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, LPCONTROLINFO pCI
)
1020 WebBrowser
*This
= impl_from_IOleControl(iface
);
1022 TRACE("(%p)->(%p)\n", This
, pCI
);
1024 /* Tests show that this function should be not implemented */
1028 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, struct tagMSG
*pMsg
)
1030 WebBrowser
*This
= impl_from_IOleControl(iface
);
1031 FIXME("(%p)->(%p)\n", This
, pMsg
);
1035 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
1037 WebBrowser
*This
= impl_from_IOleControl(iface
);
1039 TRACE("(%p)->(%ld)\n", This
, dispID
);
1042 case DISPID_UNKNOWN
:
1043 /* Unknown means multiple properties changed, so check them all.
1044 * BUT the Webbrowser OleControl object doesn't appear to do this.
1047 case DISPID_AMBIENT_DLCONTROL
:
1049 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
1050 return on_offlineconnected_change(This
);
1051 case DISPID_AMBIENT_SILENT
:
1052 return on_silent_change(This
);
1055 FIXME("Unknown dispID %ld\n", dispID
);
1059 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
1061 WebBrowser
*This
= impl_from_IOleControl(iface
);
1062 FIXME("(%p)->(%x)\n", This
, bFreeze
);
1066 static const IOleControlVtbl OleControlVtbl
=
1068 OleControl_QueryInterface
,
1071 OleControl_GetControlInfo
,
1072 OleControl_OnMnemonic
,
1073 OleControl_OnAmbientPropertyChange
,
1074 OleControl_FreezeEvents
1077 static inline WebBrowser
*impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject
*iface
)
1079 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceActiveObject_iface
);
1082 static HRESULT WINAPI
InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject
*iface
,
1083 REFIID riid
, void **ppv
)
1085 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1086 return IUnknown_QueryInterface(This
->hlink_frame
.outer
, riid
, ppv
);
1089 static ULONG WINAPI
InPlaceActiveObject_AddRef(IOleInPlaceActiveObject
*iface
)
1091 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1092 return IUnknown_AddRef(This
->hlink_frame
.outer
);
1095 static ULONG WINAPI
InPlaceActiveObject_Release(IOleInPlaceActiveObject
*iface
)
1097 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1098 return IUnknown_Release(This
->hlink_frame
.outer
);
1101 static HRESULT WINAPI
InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject
*iface
,
1104 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1105 return IOleInPlaceObject_GetWindow(&This
->IOleInPlaceObject_iface
, phwnd
);
1108 static HRESULT WINAPI
InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject
*iface
,
1111 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1112 return IOleInPlaceObject_ContextSensitiveHelp(&This
->IOleInPlaceObject_iface
, fEnterMode
);
1115 static HRESULT WINAPI
InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject
*iface
,
1118 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1119 IOleInPlaceActiveObject
*activeobj
;
1120 HRESULT hr
= S_FALSE
;
1122 TRACE("(%p)->(%p)\n", This
, lpmsg
);
1124 if(This
->doc_host
.document
) {
1125 if(SUCCEEDED(IUnknown_QueryInterface(This
->doc_host
.document
,
1126 &IID_IOleInPlaceActiveObject
,
1127 (void**)&activeobj
))) {
1128 hr
= IOleInPlaceActiveObject_TranslateAccelerator(activeobj
, lpmsg
);
1129 IOleInPlaceActiveObject_Release(activeobj
);
1139 static HRESULT WINAPI
InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject
*iface
,
1142 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1143 FIXME("(%p)->(%x)\n", This
, fActivate
);
1147 static HRESULT WINAPI
InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject
*iface
,
1150 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1151 FIXME("(%p)->(%x)\n", This
, fActivate
);
1155 static HRESULT WINAPI
InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject
*iface
,
1156 LPCRECT lprcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fFrameWindow
)
1158 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1159 FIXME("(%p)->(%p %p %x)\n", This
, lprcBorder
, pUIWindow
, fFrameWindow
);
1163 static HRESULT WINAPI
InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject
*iface
,
1166 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1167 FIXME("(%p)->(%x)\n", This
, fEnable
);
1171 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl
= {
1172 InPlaceActiveObject_QueryInterface
,
1173 InPlaceActiveObject_AddRef
,
1174 InPlaceActiveObject_Release
,
1175 InPlaceActiveObject_GetWindow
,
1176 InPlaceActiveObject_ContextSensitiveHelp
,
1177 InPlaceActiveObject_TranslateAccelerator
,
1178 InPlaceActiveObject_OnFrameWindowActivate
,
1179 InPlaceActiveObject_OnDocWindowActivate
,
1180 InPlaceActiveObject_ResizeBorder
,
1181 InPlaceActiveObject_EnableModeless
1184 static inline WebBrowser
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
1186 return CONTAINING_RECORD(iface
, WebBrowser
, IOleCommandTarget_iface
);
1189 static HRESULT WINAPI
WBOleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
1190 REFIID riid
, void **ppv
)
1192 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1193 return IUnknown_QueryInterface(This
->hlink_frame
.outer
, riid
, ppv
);
1196 static ULONG WINAPI
WBOleCommandTarget_AddRef(IOleCommandTarget
*iface
)
1198 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1199 return IUnknown_AddRef(This
->hlink_frame
.outer
);
1202 static ULONG WINAPI
WBOleCommandTarget_Release(IOleCommandTarget
*iface
)
1204 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1205 return IUnknown_Release(This
->hlink_frame
.outer
);
1208 static HRESULT WINAPI
WBOleCommandTarget_QueryStatus(IOleCommandTarget
*iface
,
1209 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
1211 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1212 IOleCommandTarget
*cmdtrg
;
1215 TRACE("(%p)->(%s %lu %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
,
1218 if(!This
->doc_host
.document
)
1221 /* NOTE: There are probably some commands that we should handle here
1222 * instead of forwarding to document object. */
1224 hres
= IUnknown_QueryInterface(This
->doc_host
.document
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1228 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
1229 IOleCommandTarget_Release(cmdtrg
);
1234 static HRESULT WINAPI
WBOleCommandTarget_Exec(IOleCommandTarget
*iface
,
1235 const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
,
1238 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1239 FIXME("(%p)->(%s %ld %ld %s %p)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
,
1240 nCmdexecopt
, debugstr_variant(pvaIn
), pvaOut
);
1244 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
1245 WBOleCommandTarget_QueryInterface
,
1246 WBOleCommandTarget_AddRef
,
1247 WBOleCommandTarget_Release
,
1248 WBOleCommandTarget_QueryStatus
,
1249 WBOleCommandTarget_Exec
1252 void WebBrowser_OleObject_Init(WebBrowser
*This
)
1258 /* default aspect ratio is 96dpi / 96dpi */
1260 dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
1261 dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
1264 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1265 This
->IOleInPlaceObject_iface
.lpVtbl
= &OleInPlaceObjectVtbl
;
1266 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1267 This
->IOleInPlaceActiveObject_iface
.lpVtbl
= &OleInPlaceActiveObjectVtbl
;
1268 This
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
1270 /* Default size is 50x20 pixels, in himetric units */
1271 This
->extent
.cx
= MulDiv( 50, 2540, dpi_x
);
1272 This
->extent
.cy
= MulDiv( 20, 2540, dpi_y
);
1275 void WebBrowser_OleObject_Destroy(WebBrowser
*This
)
1277 release_client_site(This
, TRUE
);