usp10: Fix a test to not rely on uninitialized memory.
[wine.git] / dlls / shdocvw / oleobject.c
blob81ade7b74802ce3f6b83cf4b36db0ff169b7d3e4
1 /*
2 * Implementation of IOleObject interfaces for WebBrowser control
4 * - IOleObject
5 * - IOleInPlaceObject
6 * - IOleControl
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
26 #include <string.h>
27 #include "wine/debug.h"
28 #include "shdocvw.h"
29 #include "htiframe.h"
30 #include "idispids.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
34 /* shlwapi.dll */
35 HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent);
37 static ATOM shell_embedding_atom = 0;
39 static LRESULT resize_window(WebBrowser *This, LONG width, LONG height)
41 if(This->doc_host.hwnd)
42 SetWindowPos(This->doc_host.hwnd, NULL, 0, 0, width, height,
43 SWP_NOZORDER | SWP_NOACTIVATE);
45 return 0;
48 static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
50 WebBrowser *This;
52 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
54 if(msg == WM_CREATE) {
55 This = *(WebBrowser**)lParam;
56 SetPropW(hwnd, wszTHIS, This);
57 }else {
58 This = GetPropW(hwnd, wszTHIS);
61 switch(msg) {
62 case WM_SIZE:
63 return resize_window(This, LOWORD(lParam), HIWORD(lParam));
66 return DefWindowProcW(hwnd, msg, wParam, lParam);
69 static void create_shell_embedding_hwnd(WebBrowser *This)
71 IOleInPlaceSite *inplace;
72 HWND parent = NULL;
73 HRESULT hres;
75 static const WCHAR wszShellEmbedding[] =
76 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
78 if(!shell_embedding_atom) {
79 static WNDCLASSEXW wndclass = {
80 sizeof(wndclass),
81 CS_DBLCLKS,
82 shell_embedding_proc,
83 0, 0 /* native uses 8 */, NULL, NULL, NULL,
84 (HBRUSH)COLOR_WINDOWFRAME, NULL,
85 wszShellEmbedding,
86 NULL
88 wndclass.hInstance = shdocvw_hinstance;
90 RegisterClassExW(&wndclass);
93 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace);
94 if(SUCCEEDED(hres)) {
95 IOleInPlaceSite_GetWindow(inplace, &parent);
96 IOleInPlaceSite_Release(inplace);
99 This->doc_host.frame_hwnd = This->shell_embedding_hwnd = CreateWindowExW(
100 WS_EX_WINDOWEDGE,
101 wszShellEmbedding, wszShellEmbedding,
102 WS_CLIPSIBLINGS | WS_CLIPCHILDREN
103 | (parent ? WS_CHILD | WS_TABSTOP : WS_POPUP | WS_MAXIMIZEBOX),
104 0, 0, 0, 0, parent,
105 NULL, shdocvw_hinstance, This);
107 TRACE("parent=%p hwnd=%p\n", parent, This->shell_embedding_hwnd);
110 static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site)
112 HWND parent_hwnd;
113 HRESULT hres;
115 if(This->inplace)
116 return S_OK;
118 if(!active_site)
119 return E_INVALIDARG;
121 hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite,
122 (void**)&This->inplace);
123 if(FAILED(hres)) {
124 WARN("Could not get IOleInPlaceSite\n");
125 return hres;
128 hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace);
129 if(hres != S_OK) {
130 WARN("CanInPlaceActivate returned: %08x\n", hres);
131 IOleInPlaceSite_Release(This->inplace);
132 return E_FAIL;
135 hres = IOleInPlaceSite_GetWindow(This->inplace, &parent_hwnd);
136 if(SUCCEEDED(hres))
137 SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd);
139 IOleInPlaceSite_OnInPlaceActivate(This->inplace);
141 IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow,
142 &This->pos_rect, &This->clip_rect,
143 &This->frameinfo);
145 SetWindowPos(This->shell_embedding_hwnd, NULL,
146 This->pos_rect.left, This->pos_rect.top,
147 This->pos_rect.right-This->pos_rect.left,
148 This->pos_rect.bottom-This->pos_rect.top,
149 SWP_NOZORDER | SWP_SHOWWINDOW);
151 if(This->client) {
152 IOleClientSite_ShowObject(This->client);
153 IOleClientSite_GetContainer(This->client, &This->container);
156 if(This->doc_host.frame)
157 IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd);
159 return S_OK;
162 static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site)
164 HRESULT hres;
166 static const WCHAR wszitem[] = {'i','t','e','m',0};
168 if(This->inplace)
169 return S_OK;
171 hres = activate_inplace(This, active_site);
172 if(FAILED(hres))
173 return hres;
175 IOleInPlaceSite_OnUIActivate(This->inplace);
177 if(This->doc_host.frame)
178 IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, ACTIVEOBJ(This), wszitem);
179 if(This->uiwindow)
180 IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, ACTIVEOBJ(This), wszitem);
182 if(This->doc_host.frame)
183 IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd);
185 SetFocus(This->shell_embedding_hwnd);
187 return S_OK;
190 static HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
192 IDispatch *disp = NULL;
193 DISPPARAMS dispparams = {NULL, 0};
194 HRESULT hres;
196 VariantInit(res);
198 if(!client)
199 return S_OK;
201 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
202 if(FAILED(hres)) {
203 TRACE("Could not get IDispatch\n");
204 return hres;
207 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
208 DISPATCH_PROPERTYGET, &dispparams, res, NULL, NULL);
210 IDispatch_Release(disp);
212 return hres;
215 static HRESULT on_offlineconnected_change(WebBrowser *This)
217 VARIANT offline;
219 get_client_disp_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
221 if(V_VT(&offline) == VT_BOOL)
222 IWebBrowser2_put_Offline(WEBBROWSER2(This), V_BOOL(&offline));
223 else if(V_VT(&offline) != VT_EMPTY)
224 WARN("wrong V_VT(silent) %d\n", V_VT(&offline));
226 return S_OK;
229 static HRESULT on_silent_change(WebBrowser *This)
231 VARIANT silent;
233 get_client_disp_property(This->client, DISPID_AMBIENT_SILENT, &silent);
235 if(V_VT(&silent) == VT_BOOL)
236 IWebBrowser2_put_Silent(WEBBROWSER2(This), V_BOOL(&silent));
237 else if(V_VT(&silent) != VT_EMPTY)
238 WARN("wrong V_VT(silent) %d\n", V_VT(&silent));
240 return S_OK;
243 /**********************************************************************
244 * Implement the IOleObject interface for the WebBrowser control
247 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
249 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
251 WebBrowser *This = OLEOBJ_THIS(iface);
252 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
255 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
257 WebBrowser *This = OLEOBJ_THIS(iface);
258 return IWebBrowser_AddRef(WEBBROWSER(This));
261 static ULONG WINAPI OleObject_Release(IOleObject *iface)
263 WebBrowser *This = OLEOBJ_THIS(iface);
264 return IWebBrowser_Release(WEBBROWSER(This));
267 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
269 WebBrowser *This = OLEOBJ_THIS(iface);
270 IOleContainer *container;
271 HRESULT hres;
273 TRACE("(%p)->(%p)\n", This, pClientSite);
275 if(This->client == pClientSite)
276 return S_OK;
278 if(This->doc_host.hwnd) {
279 DestroyWindow(This->doc_host.hwnd);
280 This->doc_host.hwnd = NULL;
282 if(This->shell_embedding_hwnd) {
283 DestroyWindow(This->shell_embedding_hwnd);
284 This->shell_embedding_hwnd = NULL;
287 if(This->inplace) {
288 IOleInPlaceSite_Release(This->inplace);
289 This->inplace = NULL;
292 if(This->doc_host.hostui) {
293 IDocHostUIHandler_Release(This->doc_host.hostui);
294 This->doc_host.hostui = NULL;
297 if(This->client)
298 IOleClientSite_Release(This->client);
300 This->client = pClientSite;
302 if(!pClientSite) {
303 if(This->doc_host.document)
304 deactivate_document(&This->doc_host);
305 return S_OK;
308 IOleClientSite_AddRef(pClientSite);
310 IOleClientSite_QueryInterface(This->client, &IID_IDispatch,
311 (void**)&This->doc_host.client_disp);
313 IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
314 (void**)&This->doc_host.hostui);
316 hres = IOleClientSite_GetContainer(This->client, &container);
317 if(SUCCEEDED(hres)) {
318 ITargetContainer *target_container;
320 hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
321 (void**)&target_container);
322 if(SUCCEEDED(hres)) {
323 FIXME("Unsupported ITargetContainer\n");
324 ITargetContainer_Release(target_container);
327 IOleContainer_Release(container);
330 create_shell_embedding_hwnd(This);
332 on_offlineconnected_change(This);
333 on_silent_change(This);
335 return S_OK;
338 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
340 WebBrowser *This = OLEOBJ_THIS(iface);
342 TRACE("(%p)->(%p)\n", This, ppClientSite);
344 if(!ppClientSite)
345 return E_INVALIDARG;
347 if(This->client)
348 IOleClientSite_AddRef(This->client);
349 *ppClientSite = This->client;
351 return S_OK;
354 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
355 LPCOLESTR szContainerObj)
357 WebBrowser *This = OLEOBJ_THIS(iface);
358 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
359 return E_NOTIMPL;
362 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
364 WebBrowser *This = OLEOBJ_THIS(iface);
365 FIXME("(%p)->(%d)\n", This, dwSaveOption);
366 return E_NOTIMPL;
369 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
371 WebBrowser *This = OLEOBJ_THIS(iface);
372 FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
373 return E_NOTIMPL;
376 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
377 DWORD dwWhichMoniker, LPMONIKER *ppmk)
379 WebBrowser *This = OLEOBJ_THIS(iface);
380 FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
381 return E_NOTIMPL;
384 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
385 BOOL fCreation, DWORD dwReserved)
387 WebBrowser *This = OLEOBJ_THIS(iface);
388 FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
389 return E_NOTIMPL;
392 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
393 LPDATAOBJECT *ppDataObject)
395 WebBrowser *This = OLEOBJ_THIS(iface);
396 FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
397 return E_NOTIMPL;
400 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
401 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
403 WebBrowser *This = OLEOBJ_THIS(iface);
405 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
406 lprcPosRect);
408 switch (iVerb)
410 case OLEIVERB_SHOW:
411 TRACE("OLEIVERB_SHOW\n");
412 return activate_ui(This, pActiveSite);
413 case OLEIVERB_UIACTIVATE:
414 TRACE("OLEIVERB_UIACTIVATE\n");
415 return activate_ui(This, pActiveSite);
416 case OLEIVERB_INPLACEACTIVATE:
417 TRACE("OLEIVERB_INPLACEACTIVATE\n");
418 return activate_inplace(This, pActiveSite);
419 case OLEIVERB_HIDE:
420 TRACE("OLEIVERB_HIDE\n");
421 if(This->doc_host.hwnd)
422 ShowWindow(This->doc_host.hwnd, SW_HIDE);
423 return S_OK;
424 default:
425 FIXME("stub for %d\n", iVerb);
426 break;
429 return E_NOTIMPL;
432 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
434 WebBrowser *This = OLEOBJ_THIS(iface);
435 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
436 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
439 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
441 WebBrowser *This = OLEOBJ_THIS(iface);
442 FIXME("(%p)\n", This);
443 return E_NOTIMPL;
446 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
448 WebBrowser *This = OLEOBJ_THIS(iface);
449 FIXME("(%p)\n", This);
450 return E_NOTIMPL;
453 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
455 WebBrowser *This = OLEOBJ_THIS(iface);
456 FIXME("(%p)->(%p)\n", This, pClsid);
457 return E_NOTIMPL;
460 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
461 LPOLESTR* pszUserType)
463 WebBrowser *This = OLEOBJ_THIS(iface);
464 TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
465 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
468 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
470 WebBrowser *This = OLEOBJ_THIS(iface);
472 TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
474 /* Tests show that dwDrawAspect is ignored */
475 memcpy(&This->extent, psizel, sizeof(SIZEL));
476 return S_OK;
479 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
481 WebBrowser *This = OLEOBJ_THIS(iface);
483 TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
485 /* Tests show that dwDrawAspect is ignored */
486 memcpy(psizel, &This->extent, sizeof(SIZEL));
487 return S_OK;
490 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
491 DWORD* pdwConnection)
493 WebBrowser *This = OLEOBJ_THIS(iface);
494 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
495 return E_NOTIMPL;
498 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
500 WebBrowser *This = OLEOBJ_THIS(iface);
501 FIXME("(%p)->(%d)\n", This, dwConnection);
502 return E_NOTIMPL;
505 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
507 WebBrowser *This = OLEOBJ_THIS(iface);
508 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
509 return S_OK;
512 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
514 WebBrowser *This = OLEOBJ_THIS(iface);
516 TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
518 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
519 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
521 return S_OK;
524 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
526 WebBrowser *This = OLEOBJ_THIS(iface);
527 FIXME("(%p)->(%p)\n", This, pLogpal);
528 return E_NOTIMPL;
531 #undef OLEOBJ_THIS
533 static const IOleObjectVtbl OleObjectVtbl =
535 OleObject_QueryInterface,
536 OleObject_AddRef,
537 OleObject_Release,
538 OleObject_SetClientSite,
539 OleObject_GetClientSite,
540 OleObject_SetHostNames,
541 OleObject_Close,
542 OleObject_SetMoniker,
543 OleObject_GetMoniker,
544 OleObject_InitFromData,
545 OleObject_GetClipboardData,
546 OleObject_DoVerb,
547 OleObject_EnumVerbs,
548 OleObject_Update,
549 OleObject_IsUpToDate,
550 OleObject_GetUserClassID,
551 OleObject_GetUserType,
552 OleObject_SetExtent,
553 OleObject_GetExtent,
554 OleObject_Advise,
555 OleObject_Unadvise,
556 OleObject_EnumAdvise,
557 OleObject_GetMiscStatus,
558 OleObject_SetColorScheme
561 /**********************************************************************
562 * Implement the IOleInPlaceObject interface
565 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
567 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
568 REFIID riid, LPVOID *ppobj)
570 WebBrowser *This = INPLACEOBJ_THIS(iface);
571 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
574 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
576 WebBrowser *This = INPLACEOBJ_THIS(iface);
577 return IWebBrowser_AddRef(WEBBROWSER(This));
580 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
582 WebBrowser *This = INPLACEOBJ_THIS(iface);
583 return IWebBrowser_Release(WEBBROWSER(This));
586 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
588 WebBrowser *This = INPLACEOBJ_THIS(iface);
590 TRACE("(%p)->(%p)\n", This, phwnd);
592 *phwnd = This->shell_embedding_hwnd;
593 return S_OK;
596 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
597 BOOL fEnterMode)
599 WebBrowser *This = INPLACEOBJ_THIS(iface);
600 FIXME("(%p)->(%x)\n", This, fEnterMode);
601 return E_NOTIMPL;
604 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
606 WebBrowser *This = INPLACEOBJ_THIS(iface);
607 FIXME("(%p)\n", This);
608 return E_NOTIMPL;
611 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
613 WebBrowser *This = INPLACEOBJ_THIS(iface);
614 FIXME("(%p)\n", This);
615 return E_NOTIMPL;
618 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
619 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
621 WebBrowser *This = INPLACEOBJ_THIS(iface);
623 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
625 memcpy(&This->pos_rect, lprcPosRect, sizeof(RECT));
627 if(lprcClipRect)
628 memcpy(&This->clip_rect, lprcClipRect, sizeof(RECT));
630 if(This->shell_embedding_hwnd) {
631 SetWindowPos(This->shell_embedding_hwnd, NULL,
632 lprcPosRect->left, lprcPosRect->top,
633 lprcPosRect->right-lprcPosRect->left,
634 lprcPosRect->bottom-lprcPosRect->top,
635 SWP_NOZORDER | SWP_NOACTIVATE);
638 return S_OK;
641 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
643 WebBrowser *This = INPLACEOBJ_THIS(iface);
644 FIXME("(%p)\n", This);
645 return E_NOTIMPL;
648 #undef INPLACEOBJ_THIS
650 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
652 OleInPlaceObject_QueryInterface,
653 OleInPlaceObject_AddRef,
654 OleInPlaceObject_Release,
655 OleInPlaceObject_GetWindow,
656 OleInPlaceObject_ContextSensitiveHelp,
657 OleInPlaceObject_InPlaceDeactivate,
658 OleInPlaceObject_UIDeactivate,
659 OleInPlaceObject_SetObjectRects,
660 OleInPlaceObject_ReactivateAndUndo
663 /**********************************************************************
664 * Implement the IOleControl interface
667 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
669 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
670 REFIID riid, LPVOID *ppobj)
672 WebBrowser *This = CONTROL_THIS(iface);
673 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
676 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
678 WebBrowser *This = CONTROL_THIS(iface);
679 return IWebBrowser_AddRef(WEBBROWSER(This));
682 static ULONG WINAPI OleControl_Release(IOleControl *iface)
684 WebBrowser *This = CONTROL_THIS(iface);
685 return IWebBrowser_Release(WEBBROWSER(This));
688 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
690 WebBrowser *This = CONTROL_THIS(iface);
692 TRACE("(%p)->(%p)\n", This, pCI);
694 /* Tests show that this function should be not implemented */
695 return E_NOTIMPL;
698 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
700 WebBrowser *This = CONTROL_THIS(iface);
701 FIXME("(%p)->(%p)\n", This, pMsg);
702 return E_NOTIMPL;
705 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
707 WebBrowser *This = CONTROL_THIS(iface);
709 TRACE("(%p)->(%d)\n", This, dispID);
711 switch(dispID) {
712 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
713 return on_offlineconnected_change(This);
714 case DISPID_AMBIENT_SILENT:
715 return on_silent_change(This);
718 FIXME("Unknown dispID %d\n", dispID);
719 return E_NOTIMPL;
722 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
724 WebBrowser *This = CONTROL_THIS(iface);
725 FIXME("(%p)->(%x)\n", This, bFreeze);
726 return E_NOTIMPL;
729 #undef CONTROL_THIS
731 static const IOleControlVtbl OleControlVtbl =
733 OleControl_QueryInterface,
734 OleControl_AddRef,
735 OleControl_Release,
736 OleControl_GetControlInfo,
737 OleControl_OnMnemonic,
738 OleControl_OnAmbientPropertyChange,
739 OleControl_FreezeEvents
742 #define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
744 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
745 REFIID riid, void **ppv)
747 WebBrowser *This = ACTIVEOBJ_THIS(iface);
748 return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
751 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
753 WebBrowser *This = ACTIVEOBJ_THIS(iface);
754 return IWebBrowser2_AddRef(WEBBROWSER2(This));
757 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
759 WebBrowser *This = ACTIVEOBJ_THIS(iface);
760 return IWebBrowser2_Release(WEBBROWSER2(This));
763 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
764 HWND *phwnd)
766 WebBrowser *This = ACTIVEOBJ_THIS(iface);
767 return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
770 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
771 BOOL fEnterMode)
773 WebBrowser *This = ACTIVEOBJ_THIS(iface);
774 return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
777 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
778 LPMSG lpmsg)
780 WebBrowser *This = ACTIVEOBJ_THIS(iface);
781 FIXME("(%p)->(%p)\n", This, lpmsg);
782 return E_NOTIMPL;
785 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
786 BOOL fActivate)
788 WebBrowser *This = ACTIVEOBJ_THIS(iface);
789 FIXME("(%p)->(%x)\n", This, fActivate);
790 return E_NOTIMPL;
793 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
794 BOOL fActivate)
796 WebBrowser *This = ACTIVEOBJ_THIS(iface);
797 FIXME("(%p)->(%x)\n", This, fActivate);
798 return E_NOTIMPL;
801 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
802 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
804 WebBrowser *This = ACTIVEOBJ_THIS(iface);
805 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
806 return E_NOTIMPL;
809 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
810 BOOL fEnable)
812 WebBrowser *This = ACTIVEOBJ_THIS(iface);
813 FIXME("(%p)->(%x)\n", This, fEnable);
814 return E_NOTIMPL;
817 #undef ACTIVEOBJ_THIS
819 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
820 InPlaceActiveObject_QueryInterface,
821 InPlaceActiveObject_AddRef,
822 InPlaceActiveObject_Release,
823 InPlaceActiveObject_GetWindow,
824 InPlaceActiveObject_ContextSensitiveHelp,
825 InPlaceActiveObject_TranslateAccelerator,
826 InPlaceActiveObject_OnFrameWindowActivate,
827 InPlaceActiveObject_OnDocWindowActivate,
828 InPlaceActiveObject_ResizeBorder,
829 InPlaceActiveObject_EnableModeless
832 #define OLECMD_THIS(iface) DEFINE_THIS(WebBrowser, OleCommandTarget, iface)
834 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
835 REFIID riid, void **ppv)
837 WebBrowser *This = OLECMD_THIS(iface);
838 return IWebBrowser2_QueryInterface(WEBBROWSER(This), riid, ppv);
841 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
843 WebBrowser *This = OLECMD_THIS(iface);
844 return IWebBrowser2_AddRef(WEBBROWSER(This));
847 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
849 WebBrowser *This = OLECMD_THIS(iface);
850 return IWebBrowser2_Release(WEBBROWSER(This));
853 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
854 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
856 WebBrowser *This = OLECMD_THIS(iface);
857 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
858 pCmdText);
859 return E_NOTIMPL;
862 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
863 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
864 VARIANT *pvaOut)
866 WebBrowser *This = OLECMD_THIS(iface);
867 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
868 nCmdexecopt, pvaIn, pvaOut);
869 return E_NOTIMPL;
872 #undef OLECMD_THIS
874 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
875 WBOleCommandTarget_QueryInterface,
876 WBOleCommandTarget_AddRef,
877 WBOleCommandTarget_Release,
878 WBOleCommandTarget_QueryStatus,
879 WBOleCommandTarget_Exec
882 void WebBrowser_OleObject_Init(WebBrowser *This)
884 This->lpOleObjectVtbl = &OleObjectVtbl;
885 This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
886 This->lpOleControlVtbl = &OleControlVtbl;
887 This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
888 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
890 This->client = NULL;
891 This->inplace = NULL;
892 This->container = NULL;
893 This->frame_hwnd = NULL;
894 This->uiwindow = NULL;
895 This->shell_embedding_hwnd = NULL;
897 memset(&This->pos_rect, 0, sizeof(RECT));
898 memset(&This->clip_rect, 0, sizeof(RECT));
899 memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
901 This->extent.cx = 1323;
902 This->extent.cy = 529;
905 void WebBrowser_OleObject_Destroy(WebBrowser *This)
907 if(This->client)
908 IOleObject_SetClientSite(OLEOBJ(This), NULL);
909 if(This->container)
910 IOleContainer_Release(This->container);
911 if(This->uiwindow)
912 IOleInPlaceUIWindow_Release(This->uiwindow);