winecfg: Add ability to change colors and non-client sizes.
[wine.git] / dlls / shdocvw / oleobject.c
blobdc795f8c9443d2f072d83310796d87c8f148066d
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->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->frame)
157 IOleInPlaceFrame_GetWindow(This->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->frame)
178 IOleInPlaceFrame_SetActiveObject(This->frame, ACTIVEOBJ(This), wszitem);
179 if(This->uiwindow)
180 IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, ACTIVEOBJ(This), wszitem);
182 if(This->frame)
183 IOleInPlaceFrame_SetMenu(This->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 if(This->client)
295 IOleClientSite_Release(This->client);
297 if(!pClientSite) {
298 if(This->doc_host.document)
299 deactivate_document(&This->doc_host);
300 This->client = NULL;
301 return S_OK;
304 This->client = pClientSite;
305 IOleClientSite_AddRef(pClientSite);
307 hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
308 (void**)&This->doc_host.hostui);
309 if(FAILED(hres))
310 This->doc_host.hostui = NULL;
312 hres = IOleClientSite_GetContainer(This->client, &container);
313 if(SUCCEEDED(hres)) {
314 ITargetContainer *target_container;
316 hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
317 (void**)&target_container);
318 if(SUCCEEDED(hres)) {
319 FIXME("Unsupported ITargetContainer\n");
320 ITargetContainer_Release(target_container);
323 IOleContainer_Release(container);
326 create_shell_embedding_hwnd(This);
328 on_offlineconnected_change(This);
329 on_silent_change(This);
331 return S_OK;
334 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
336 WebBrowser *This = OLEOBJ_THIS(iface);
338 TRACE("(%p)->(%p)\n", This, ppClientSite);
340 if(!ppClientSite)
341 return E_INVALIDARG;
343 if(This->client)
344 IOleClientSite_AddRef(This->client);
345 *ppClientSite = This->client;
347 return S_OK;
350 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
351 LPCOLESTR szContainerObj)
353 WebBrowser *This = OLEOBJ_THIS(iface);
354 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
355 return E_NOTIMPL;
358 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
360 WebBrowser *This = OLEOBJ_THIS(iface);
361 FIXME("(%p)->(%d)\n", This, dwSaveOption);
362 return E_NOTIMPL;
365 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
367 WebBrowser *This = OLEOBJ_THIS(iface);
368 FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
369 return E_NOTIMPL;
372 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
373 DWORD dwWhichMoniker, LPMONIKER *ppmk)
375 WebBrowser *This = OLEOBJ_THIS(iface);
376 FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
377 return E_NOTIMPL;
380 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
381 BOOL fCreation, DWORD dwReserved)
383 WebBrowser *This = OLEOBJ_THIS(iface);
384 FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
385 return E_NOTIMPL;
388 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
389 LPDATAOBJECT *ppDataObject)
391 WebBrowser *This = OLEOBJ_THIS(iface);
392 FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
393 return E_NOTIMPL;
396 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
397 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
399 WebBrowser *This = OLEOBJ_THIS(iface);
401 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
402 lprcPosRect);
404 switch (iVerb)
406 case OLEIVERB_SHOW:
407 TRACE("OLEIVERB_SHOW\n");
408 return activate_ui(This, pActiveSite);
409 case OLEIVERB_UIACTIVATE:
410 TRACE("OLEIVERB_UIACTIVATE\n");
411 return activate_ui(This, pActiveSite);
412 case OLEIVERB_INPLACEACTIVATE:
413 TRACE("OLEIVERB_INPLACEACTIVATE\n");
414 return activate_inplace(This, pActiveSite);
415 default:
416 FIXME("stub for %d\n", iVerb);
417 break;
420 return E_NOTIMPL;
423 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
425 WebBrowser *This = OLEOBJ_THIS(iface);
426 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
427 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
430 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
432 WebBrowser *This = OLEOBJ_THIS(iface);
433 FIXME("(%p)\n", This);
434 return E_NOTIMPL;
437 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
439 WebBrowser *This = OLEOBJ_THIS(iface);
440 FIXME("(%p)\n", This);
441 return E_NOTIMPL;
444 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
446 WebBrowser *This = OLEOBJ_THIS(iface);
447 FIXME("(%p)->(%p)\n", This, pClsid);
448 return E_NOTIMPL;
451 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
452 LPOLESTR* pszUserType)
454 WebBrowser *This = OLEOBJ_THIS(iface);
455 TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
456 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
459 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
461 WebBrowser *This = OLEOBJ_THIS(iface);
463 TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
465 /* Tests show that dwDrawAspect is ignored */
466 memcpy(&This->extent, psizel, sizeof(SIZEL));
467 return S_OK;
470 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
472 WebBrowser *This = OLEOBJ_THIS(iface);
474 TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
476 /* Tests show that dwDrawAspect is ignored */
477 memcpy(psizel, &This->extent, sizeof(SIZEL));
478 return S_OK;
481 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
482 DWORD* pdwConnection)
484 WebBrowser *This = OLEOBJ_THIS(iface);
485 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
486 return E_NOTIMPL;
489 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
491 WebBrowser *This = OLEOBJ_THIS(iface);
492 FIXME("(%p)->(%d)\n", This, dwConnection);
493 return E_NOTIMPL;
496 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
498 WebBrowser *This = OLEOBJ_THIS(iface);
499 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
500 return S_OK;
503 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
505 WebBrowser *This = OLEOBJ_THIS(iface);
507 TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
509 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
510 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
512 return S_OK;
515 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
517 WebBrowser *This = OLEOBJ_THIS(iface);
518 FIXME("(%p)->(%p)\n", This, pLogpal);
519 return E_NOTIMPL;
522 #undef OLEOBJ_THIS
524 static const IOleObjectVtbl OleObjectVtbl =
526 OleObject_QueryInterface,
527 OleObject_AddRef,
528 OleObject_Release,
529 OleObject_SetClientSite,
530 OleObject_GetClientSite,
531 OleObject_SetHostNames,
532 OleObject_Close,
533 OleObject_SetMoniker,
534 OleObject_GetMoniker,
535 OleObject_InitFromData,
536 OleObject_GetClipboardData,
537 OleObject_DoVerb,
538 OleObject_EnumVerbs,
539 OleObject_Update,
540 OleObject_IsUpToDate,
541 OleObject_GetUserClassID,
542 OleObject_GetUserType,
543 OleObject_SetExtent,
544 OleObject_GetExtent,
545 OleObject_Advise,
546 OleObject_Unadvise,
547 OleObject_EnumAdvise,
548 OleObject_GetMiscStatus,
549 OleObject_SetColorScheme
552 /**********************************************************************
553 * Implement the IOleInPlaceObject interface
556 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
558 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
559 REFIID riid, LPVOID *ppobj)
561 WebBrowser *This = INPLACEOBJ_THIS(iface);
562 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
565 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
567 WebBrowser *This = INPLACEOBJ_THIS(iface);
568 return IWebBrowser_AddRef(WEBBROWSER(This));
571 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
573 WebBrowser *This = INPLACEOBJ_THIS(iface);
574 return IWebBrowser_Release(WEBBROWSER(This));
577 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
579 WebBrowser *This = INPLACEOBJ_THIS(iface);
581 TRACE("(%p)->(%p)\n", This, phwnd);
583 *phwnd = This->shell_embedding_hwnd;
584 return S_OK;
587 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
588 BOOL fEnterMode)
590 WebBrowser *This = INPLACEOBJ_THIS(iface);
591 FIXME("(%p)->(%x)\n", This, fEnterMode);
592 return E_NOTIMPL;
595 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
597 WebBrowser *This = INPLACEOBJ_THIS(iface);
598 FIXME("(%p)\n", This);
599 return E_NOTIMPL;
602 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
604 WebBrowser *This = INPLACEOBJ_THIS(iface);
605 FIXME("(%p)\n", This);
606 return E_NOTIMPL;
609 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
610 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
612 WebBrowser *This = INPLACEOBJ_THIS(iface);
614 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
616 memcpy(&This->pos_rect, lprcPosRect, sizeof(RECT));
618 if(lprcClipRect)
619 memcpy(&This->clip_rect, lprcClipRect, sizeof(RECT));
621 if(This->shell_embedding_hwnd) {
622 SetWindowPos(This->shell_embedding_hwnd, NULL,
623 lprcPosRect->left, lprcPosRect->top,
624 lprcPosRect->right-lprcPosRect->left,
625 lprcPosRect->bottom-lprcPosRect->top,
626 SWP_NOZORDER | SWP_NOACTIVATE);
629 return S_OK;
632 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
634 WebBrowser *This = INPLACEOBJ_THIS(iface);
635 FIXME("(%p)\n", This);
636 return E_NOTIMPL;
639 #undef INPLACEOBJ_THIS
641 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
643 OleInPlaceObject_QueryInterface,
644 OleInPlaceObject_AddRef,
645 OleInPlaceObject_Release,
646 OleInPlaceObject_GetWindow,
647 OleInPlaceObject_ContextSensitiveHelp,
648 OleInPlaceObject_InPlaceDeactivate,
649 OleInPlaceObject_UIDeactivate,
650 OleInPlaceObject_SetObjectRects,
651 OleInPlaceObject_ReactivateAndUndo
654 /**********************************************************************
655 * Implement the IOleControl interface
658 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
660 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
661 REFIID riid, LPVOID *ppobj)
663 WebBrowser *This = CONTROL_THIS(iface);
664 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
667 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
669 WebBrowser *This = CONTROL_THIS(iface);
670 return IWebBrowser_AddRef(WEBBROWSER(This));
673 static ULONG WINAPI OleControl_Release(IOleControl *iface)
675 WebBrowser *This = CONTROL_THIS(iface);
676 return IWebBrowser_Release(WEBBROWSER(This));
679 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
681 WebBrowser *This = CONTROL_THIS(iface);
683 TRACE("(%p)->(%p)\n", This, pCI);
685 /* Tests show that this function should be not implemented */
686 return E_NOTIMPL;
689 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
691 WebBrowser *This = CONTROL_THIS(iface);
692 FIXME("(%p)->(%p)\n", This, pMsg);
693 return E_NOTIMPL;
696 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
698 WebBrowser *This = CONTROL_THIS(iface);
700 TRACE("(%p)->(%d)\n", This, dispID);
702 switch(dispID) {
703 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
704 return on_offlineconnected_change(This);
705 case DISPID_AMBIENT_SILENT:
706 return on_silent_change(This);
709 FIXME("Unknown dispID %d\n", dispID);
710 return E_NOTIMPL;
713 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
715 WebBrowser *This = CONTROL_THIS(iface);
716 FIXME("(%p)->(%x)\n", This, bFreeze);
717 return E_NOTIMPL;
720 #undef CONTROL_THIS
722 static const IOleControlVtbl OleControlVtbl =
724 OleControl_QueryInterface,
725 OleControl_AddRef,
726 OleControl_Release,
727 OleControl_GetControlInfo,
728 OleControl_OnMnemonic,
729 OleControl_OnAmbientPropertyChange,
730 OleControl_FreezeEvents
733 #define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
735 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
736 REFIID riid, void **ppv)
738 WebBrowser *This = ACTIVEOBJ_THIS(iface);
739 return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
742 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
744 WebBrowser *This = ACTIVEOBJ_THIS(iface);
745 return IWebBrowser2_AddRef(WEBBROWSER2(This));
748 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
750 WebBrowser *This = ACTIVEOBJ_THIS(iface);
751 return IWebBrowser2_Release(WEBBROWSER2(This));
754 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
755 HWND *phwnd)
757 WebBrowser *This = ACTIVEOBJ_THIS(iface);
758 return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
761 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
762 BOOL fEnterMode)
764 WebBrowser *This = ACTIVEOBJ_THIS(iface);
765 return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
768 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
769 LPMSG lpmsg)
771 WebBrowser *This = ACTIVEOBJ_THIS(iface);
772 FIXME("(%p)->(%p)\n", This, lpmsg);
773 return E_NOTIMPL;
776 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
777 BOOL fActivate)
779 WebBrowser *This = ACTIVEOBJ_THIS(iface);
780 FIXME("(%p)->(%x)\n", This, fActivate);
781 return E_NOTIMPL;
784 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
785 BOOL fActivate)
787 WebBrowser *This = ACTIVEOBJ_THIS(iface);
788 FIXME("(%p)->(%x)\n", This, fActivate);
789 return E_NOTIMPL;
792 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
793 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
795 WebBrowser *This = ACTIVEOBJ_THIS(iface);
796 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
797 return E_NOTIMPL;
800 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
801 BOOL fEnable)
803 WebBrowser *This = ACTIVEOBJ_THIS(iface);
804 FIXME("(%p)->(%x)\n", This, fEnable);
805 return E_NOTIMPL;
808 #undef ACTIVEOBJ_THIS
810 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
811 InPlaceActiveObject_QueryInterface,
812 InPlaceActiveObject_AddRef,
813 InPlaceActiveObject_Release,
814 InPlaceActiveObject_GetWindow,
815 InPlaceActiveObject_ContextSensitiveHelp,
816 InPlaceActiveObject_TranslateAccelerator,
817 InPlaceActiveObject_OnFrameWindowActivate,
818 InPlaceActiveObject_OnDocWindowActivate,
819 InPlaceActiveObject_ResizeBorder,
820 InPlaceActiveObject_EnableModeless
823 #define OLECMD_THIS(iface) DEFINE_THIS(WebBrowser, OleCommandTarget, iface)
825 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
826 REFIID riid, void **ppv)
828 WebBrowser *This = OLECMD_THIS(iface);
829 return IWebBrowser2_QueryInterface(WEBBROWSER(This), riid, ppv);
832 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
834 WebBrowser *This = OLECMD_THIS(iface);
835 return IWebBrowser2_AddRef(WEBBROWSER(This));
838 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
840 WebBrowser *This = OLECMD_THIS(iface);
841 return IWebBrowser2_Release(WEBBROWSER(This));
844 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
845 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
847 WebBrowser *This = OLECMD_THIS(iface);
848 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
849 pCmdText);
850 return E_NOTIMPL;
853 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
854 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
855 VARIANT *pvaOut)
857 WebBrowser *This = OLECMD_THIS(iface);
858 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
859 nCmdexecopt, pvaIn, pvaOut);
860 return E_NOTIMPL;
863 #undef OLECMD_THIS
865 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
866 WBOleCommandTarget_QueryInterface,
867 WBOleCommandTarget_AddRef,
868 WBOleCommandTarget_Release,
869 WBOleCommandTarget_QueryStatus,
870 WBOleCommandTarget_Exec
873 void WebBrowser_OleObject_Init(WebBrowser *This)
875 This->lpOleObjectVtbl = &OleObjectVtbl;
876 This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
877 This->lpOleControlVtbl = &OleControlVtbl;
878 This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
879 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
881 This->client = NULL;
882 This->inplace = NULL;
883 This->container = NULL;
884 This->frame_hwnd = NULL;
885 This->frame = NULL;
886 This->uiwindow = NULL;
887 This->shell_embedding_hwnd = NULL;
889 memset(&This->pos_rect, 0, sizeof(RECT));
890 memset(&This->clip_rect, 0, sizeof(RECT));
891 memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
893 This->extent.cx = 1323;
894 This->extent.cy = 529;
897 void WebBrowser_OleObject_Destroy(WebBrowser *This)
899 if(This->client)
900 IOleObject_SetClientSite(OLEOBJ(This), NULL);
901 if(This->container)
902 IOleContainer_Release(This->container);
903 if(This->frame)
904 IOleInPlaceFrame_Release(This->frame);
905 if(This->uiwindow)
906 IOleInPlaceUIWindow_Release(This->uiwindow);