oleaut32: Handle strings with a length of 0xffff in SLTG_DoVars.
[wine/gsoc_dplay.git] / dlls / shdocvw / oleobject.c
blobb8ed625b915024e3c5586d65237b32e9457e3d6f
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));
64 case WM_DOCHOSTTASK:
65 return process_dochost_task(&This->doc_host, lParam);
68 return DefWindowProcW(hwnd, msg, wParam, lParam);
71 static void create_shell_embedding_hwnd(WebBrowser *This)
73 IOleInPlaceSite *inplace;
74 HWND parent = NULL;
75 HRESULT hres;
77 static const WCHAR wszShellEmbedding[] =
78 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
80 if(!shell_embedding_atom) {
81 static WNDCLASSEXW wndclass = {
82 sizeof(wndclass),
83 CS_DBLCLKS,
84 shell_embedding_proc,
85 0, 0 /* native uses 8 */, NULL, NULL, NULL,
86 (HBRUSH)COLOR_WINDOWFRAME, NULL,
87 wszShellEmbedding,
88 NULL
90 wndclass.hInstance = shdocvw_hinstance;
92 RegisterClassExW(&wndclass);
95 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace);
96 if(SUCCEEDED(hres)) {
97 IOleInPlaceSite_GetWindow(inplace, &parent);
98 IOleInPlaceSite_Release(inplace);
101 This->doc_host.frame_hwnd = This->shell_embedding_hwnd = CreateWindowExW(
102 WS_EX_WINDOWEDGE,
103 wszShellEmbedding, wszShellEmbedding,
104 WS_CLIPSIBLINGS | WS_CLIPCHILDREN
105 | (parent ? WS_CHILD | WS_TABSTOP : WS_POPUP | WS_MAXIMIZEBOX),
106 0, 0, 0, 0, parent,
107 NULL, shdocvw_hinstance, This);
109 TRACE("parent=%p hwnd=%p\n", parent, This->shell_embedding_hwnd);
112 static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site)
114 HWND parent_hwnd;
115 HRESULT hres;
117 if(This->inplace)
118 return S_OK;
120 if(!active_site)
121 return E_INVALIDARG;
123 hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite,
124 (void**)&This->inplace);
125 if(FAILED(hres)) {
126 WARN("Could not get IOleInPlaceSite\n");
127 return hres;
130 hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace);
131 if(hres != S_OK) {
132 WARN("CanInPlaceActivate returned: %08x\n", hres);
133 IOleInPlaceSite_Release(This->inplace);
134 return E_FAIL;
137 hres = IOleInPlaceSite_GetWindow(This->inplace, &parent_hwnd);
138 if(SUCCEEDED(hres))
139 SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd);
141 IOleInPlaceSite_OnInPlaceActivate(This->inplace);
143 IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow,
144 &This->pos_rect, &This->clip_rect,
145 &This->frameinfo);
147 SetWindowPos(This->shell_embedding_hwnd, NULL,
148 This->pos_rect.left, This->pos_rect.top,
149 This->pos_rect.right-This->pos_rect.left,
150 This->pos_rect.bottom-This->pos_rect.top,
151 SWP_NOZORDER | SWP_SHOWWINDOW);
153 if(This->client) {
154 IOleClientSite_ShowObject(This->client);
155 IOleClientSite_GetContainer(This->client, &This->container);
158 if(This->doc_host.frame)
159 IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd);
161 return S_OK;
164 static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site)
166 HRESULT hres;
168 static const WCHAR wszitem[] = {'i','t','e','m',0};
170 if(This->inplace)
172 if(This->shell_embedding_hwnd)
173 ShowWindow(This->shell_embedding_hwnd, SW_SHOW);
174 return S_OK;
177 hres = activate_inplace(This, active_site);
178 if(FAILED(hres))
179 return hres;
181 IOleInPlaceSite_OnUIActivate(This->inplace);
183 if(This->doc_host.frame)
184 IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, ACTIVEOBJ(This), wszitem);
185 if(This->uiwindow)
186 IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, ACTIVEOBJ(This), wszitem);
188 if(This->doc_host.frame)
189 IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd);
191 SetFocus(This->shell_embedding_hwnd);
193 return S_OK;
196 static HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
198 IDispatch *disp = NULL;
199 DISPPARAMS dispparams = {NULL, 0};
200 HRESULT hres;
202 VariantInit(res);
204 if(!client)
205 return S_OK;
207 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
208 if(FAILED(hres)) {
209 TRACE("Could not get IDispatch\n");
210 return hres;
213 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
214 DISPATCH_PROPERTYGET, &dispparams, res, NULL, NULL);
216 IDispatch_Release(disp);
218 return hres;
221 static HRESULT on_offlineconnected_change(WebBrowser *This)
223 VARIANT offline;
225 get_client_disp_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
227 if(V_VT(&offline) == VT_BOOL)
228 IWebBrowser2_put_Offline(WEBBROWSER2(This), V_BOOL(&offline));
229 else if(V_VT(&offline) != VT_EMPTY)
230 WARN("wrong V_VT(silent) %d\n", V_VT(&offline));
232 return S_OK;
235 static HRESULT on_silent_change(WebBrowser *This)
237 VARIANT silent;
239 get_client_disp_property(This->client, DISPID_AMBIENT_SILENT, &silent);
241 if(V_VT(&silent) == VT_BOOL)
242 IWebBrowser2_put_Silent(WEBBROWSER2(This), V_BOOL(&silent));
243 else if(V_VT(&silent) != VT_EMPTY)
244 WARN("wrong V_VT(silent) %d\n", V_VT(&silent));
246 return S_OK;
249 /**********************************************************************
250 * Implement the IOleObject interface for the WebBrowser control
253 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
255 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
257 WebBrowser *This = OLEOBJ_THIS(iface);
258 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
261 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
263 WebBrowser *This = OLEOBJ_THIS(iface);
264 return IWebBrowser_AddRef(WEBBROWSER(This));
267 static ULONG WINAPI OleObject_Release(IOleObject *iface)
269 WebBrowser *This = OLEOBJ_THIS(iface);
270 return IWebBrowser_Release(WEBBROWSER(This));
273 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
275 WebBrowser *This = OLEOBJ_THIS(iface);
276 IOleContainer *container;
277 HRESULT hres;
279 TRACE("(%p)->(%p)\n", This, pClientSite);
281 if(This->client == pClientSite)
282 return S_OK;
284 if(This->doc_host.hwnd) {
285 DestroyWindow(This->doc_host.hwnd);
286 This->doc_host.hwnd = NULL;
288 if(This->shell_embedding_hwnd) {
289 DestroyWindow(This->shell_embedding_hwnd);
290 This->shell_embedding_hwnd = NULL;
293 if(This->inplace) {
294 IOleInPlaceSite_Release(This->inplace);
295 This->inplace = NULL;
298 if(This->doc_host.hostui) {
299 IDocHostUIHandler_Release(This->doc_host.hostui);
300 This->doc_host.hostui = NULL;
303 if(This->client)
304 IOleClientSite_Release(This->client);
306 This->client = pClientSite;
308 if(!pClientSite) {
309 if(This->doc_host.document)
310 deactivate_document(&This->doc_host);
311 return S_OK;
314 IOleClientSite_AddRef(pClientSite);
316 IOleClientSite_QueryInterface(This->client, &IID_IDispatch,
317 (void**)&This->doc_host.client_disp);
319 IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
320 (void**)&This->doc_host.hostui);
322 hres = IOleClientSite_GetContainer(This->client, &container);
323 if(SUCCEEDED(hres)) {
324 ITargetContainer *target_container;
326 hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
327 (void**)&target_container);
328 if(SUCCEEDED(hres)) {
329 FIXME("Unsupported ITargetContainer\n");
330 ITargetContainer_Release(target_container);
333 IOleContainer_Release(container);
336 create_shell_embedding_hwnd(This);
338 on_offlineconnected_change(This);
339 on_silent_change(This);
341 return S_OK;
344 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
346 WebBrowser *This = OLEOBJ_THIS(iface);
348 TRACE("(%p)->(%p)\n", This, ppClientSite);
350 if(!ppClientSite)
351 return E_INVALIDARG;
353 if(This->client)
354 IOleClientSite_AddRef(This->client);
355 *ppClientSite = This->client;
357 return S_OK;
360 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
361 LPCOLESTR szContainerObj)
363 WebBrowser *This = OLEOBJ_THIS(iface);
365 TRACE("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
367 /* We have nothing to do here. */
368 return S_OK;
371 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
373 WebBrowser *This = OLEOBJ_THIS(iface);
374 FIXME("(%p)->(%d)\n", This, dwSaveOption);
375 return E_NOTIMPL;
378 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
380 WebBrowser *This = OLEOBJ_THIS(iface);
381 FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
382 return E_NOTIMPL;
385 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
386 DWORD dwWhichMoniker, LPMONIKER *ppmk)
388 WebBrowser *This = OLEOBJ_THIS(iface);
389 FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
390 return E_NOTIMPL;
393 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
394 BOOL fCreation, DWORD dwReserved)
396 WebBrowser *This = OLEOBJ_THIS(iface);
397 FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
398 return E_NOTIMPL;
401 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
402 LPDATAOBJECT *ppDataObject)
404 WebBrowser *This = OLEOBJ_THIS(iface);
405 FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
406 return E_NOTIMPL;
409 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
410 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
412 WebBrowser *This = OLEOBJ_THIS(iface);
414 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
415 lprcPosRect);
417 switch (iVerb)
419 case OLEIVERB_SHOW:
420 TRACE("OLEIVERB_SHOW\n");
421 return activate_ui(This, pActiveSite);
422 case OLEIVERB_UIACTIVATE:
423 TRACE("OLEIVERB_UIACTIVATE\n");
424 return activate_ui(This, pActiveSite);
425 case OLEIVERB_INPLACEACTIVATE:
426 TRACE("OLEIVERB_INPLACEACTIVATE\n");
427 return activate_inplace(This, pActiveSite);
428 case OLEIVERB_HIDE:
429 TRACE("OLEIVERB_HIDE\n");
430 if(This->shell_embedding_hwnd)
431 ShowWindow(This->shell_embedding_hwnd, SW_HIDE);
432 return S_OK;
433 default:
434 FIXME("stub for %d\n", iVerb);
435 break;
438 return E_NOTIMPL;
441 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
443 WebBrowser *This = OLEOBJ_THIS(iface);
444 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
445 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
448 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
450 WebBrowser *This = OLEOBJ_THIS(iface);
451 FIXME("(%p)\n", This);
452 return E_NOTIMPL;
455 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
457 WebBrowser *This = OLEOBJ_THIS(iface);
458 FIXME("(%p)\n", This);
459 return E_NOTIMPL;
462 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
464 WebBrowser *This = OLEOBJ_THIS(iface);
465 FIXME("(%p)->(%p)\n", This, pClsid);
466 return E_NOTIMPL;
469 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
470 LPOLESTR* pszUserType)
472 WebBrowser *This = OLEOBJ_THIS(iface);
473 TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
474 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
477 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
479 WebBrowser *This = OLEOBJ_THIS(iface);
481 TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
483 /* Tests show that dwDrawAspect is ignored */
484 This->extent = *psizel;
485 return S_OK;
488 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
490 WebBrowser *This = OLEOBJ_THIS(iface);
492 TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
494 /* Tests show that dwDrawAspect is ignored */
495 *psizel = This->extent;
496 return S_OK;
499 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
500 DWORD* pdwConnection)
502 WebBrowser *This = OLEOBJ_THIS(iface);
503 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
504 return E_NOTIMPL;
507 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
509 WebBrowser *This = OLEOBJ_THIS(iface);
510 FIXME("(%p)->(%d)\n", This, dwConnection);
511 return E_NOTIMPL;
514 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
516 WebBrowser *This = OLEOBJ_THIS(iface);
517 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
518 return S_OK;
521 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
523 WebBrowser *This = OLEOBJ_THIS(iface);
525 TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
527 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
528 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
530 return S_OK;
533 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
535 WebBrowser *This = OLEOBJ_THIS(iface);
536 FIXME("(%p)->(%p)\n", This, pLogpal);
537 return E_NOTIMPL;
540 #undef OLEOBJ_THIS
542 static const IOleObjectVtbl OleObjectVtbl =
544 OleObject_QueryInterface,
545 OleObject_AddRef,
546 OleObject_Release,
547 OleObject_SetClientSite,
548 OleObject_GetClientSite,
549 OleObject_SetHostNames,
550 OleObject_Close,
551 OleObject_SetMoniker,
552 OleObject_GetMoniker,
553 OleObject_InitFromData,
554 OleObject_GetClipboardData,
555 OleObject_DoVerb,
556 OleObject_EnumVerbs,
557 OleObject_Update,
558 OleObject_IsUpToDate,
559 OleObject_GetUserClassID,
560 OleObject_GetUserType,
561 OleObject_SetExtent,
562 OleObject_GetExtent,
563 OleObject_Advise,
564 OleObject_Unadvise,
565 OleObject_EnumAdvise,
566 OleObject_GetMiscStatus,
567 OleObject_SetColorScheme
570 /**********************************************************************
571 * Implement the IOleInPlaceObject interface
574 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
576 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
577 REFIID riid, LPVOID *ppobj)
579 WebBrowser *This = INPLACEOBJ_THIS(iface);
580 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
583 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
585 WebBrowser *This = INPLACEOBJ_THIS(iface);
586 return IWebBrowser_AddRef(WEBBROWSER(This));
589 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
591 WebBrowser *This = INPLACEOBJ_THIS(iface);
592 return IWebBrowser_Release(WEBBROWSER(This));
595 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
597 WebBrowser *This = INPLACEOBJ_THIS(iface);
599 TRACE("(%p)->(%p)\n", This, phwnd);
601 *phwnd = This->shell_embedding_hwnd;
602 return S_OK;
605 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
606 BOOL fEnterMode)
608 WebBrowser *This = INPLACEOBJ_THIS(iface);
609 FIXME("(%p)->(%x)\n", This, fEnterMode);
610 return E_NOTIMPL;
613 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
615 WebBrowser *This = INPLACEOBJ_THIS(iface);
616 FIXME("(%p)\n", This);
617 return E_NOTIMPL;
620 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
622 WebBrowser *This = INPLACEOBJ_THIS(iface);
623 FIXME("(%p)\n", This);
624 return E_NOTIMPL;
627 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
628 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
630 WebBrowser *This = INPLACEOBJ_THIS(iface);
632 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
634 This->pos_rect = *lprcPosRect;
636 if(lprcClipRect)
637 This->clip_rect = *lprcClipRect;
639 if(This->shell_embedding_hwnd) {
640 SetWindowPos(This->shell_embedding_hwnd, NULL,
641 lprcPosRect->left, lprcPosRect->top,
642 lprcPosRect->right-lprcPosRect->left,
643 lprcPosRect->bottom-lprcPosRect->top,
644 SWP_NOZORDER | SWP_NOACTIVATE);
647 return S_OK;
650 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
652 WebBrowser *This = INPLACEOBJ_THIS(iface);
653 FIXME("(%p)\n", This);
654 return E_NOTIMPL;
657 #undef INPLACEOBJ_THIS
659 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
661 OleInPlaceObject_QueryInterface,
662 OleInPlaceObject_AddRef,
663 OleInPlaceObject_Release,
664 OleInPlaceObject_GetWindow,
665 OleInPlaceObject_ContextSensitiveHelp,
666 OleInPlaceObject_InPlaceDeactivate,
667 OleInPlaceObject_UIDeactivate,
668 OleInPlaceObject_SetObjectRects,
669 OleInPlaceObject_ReactivateAndUndo
672 /**********************************************************************
673 * Implement the IOleControl interface
676 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
678 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
679 REFIID riid, LPVOID *ppobj)
681 WebBrowser *This = CONTROL_THIS(iface);
682 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
685 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
687 WebBrowser *This = CONTROL_THIS(iface);
688 return IWebBrowser_AddRef(WEBBROWSER(This));
691 static ULONG WINAPI OleControl_Release(IOleControl *iface)
693 WebBrowser *This = CONTROL_THIS(iface);
694 return IWebBrowser_Release(WEBBROWSER(This));
697 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
699 WebBrowser *This = CONTROL_THIS(iface);
701 TRACE("(%p)->(%p)\n", This, pCI);
703 /* Tests show that this function should be not implemented */
704 return E_NOTIMPL;
707 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
709 WebBrowser *This = CONTROL_THIS(iface);
710 FIXME("(%p)->(%p)\n", This, pMsg);
711 return E_NOTIMPL;
714 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
716 WebBrowser *This = CONTROL_THIS(iface);
718 TRACE("(%p)->(%d)\n", This, dispID);
720 switch(dispID) {
721 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
722 return on_offlineconnected_change(This);
723 case DISPID_AMBIENT_SILENT:
724 return on_silent_change(This);
727 FIXME("Unknown dispID %d\n", dispID);
728 return E_NOTIMPL;
731 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
733 WebBrowser *This = CONTROL_THIS(iface);
734 FIXME("(%p)->(%x)\n", This, bFreeze);
735 return E_NOTIMPL;
738 #undef CONTROL_THIS
740 static const IOleControlVtbl OleControlVtbl =
742 OleControl_QueryInterface,
743 OleControl_AddRef,
744 OleControl_Release,
745 OleControl_GetControlInfo,
746 OleControl_OnMnemonic,
747 OleControl_OnAmbientPropertyChange,
748 OleControl_FreezeEvents
751 #define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
753 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
754 REFIID riid, void **ppv)
756 WebBrowser *This = ACTIVEOBJ_THIS(iface);
757 return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
760 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
762 WebBrowser *This = ACTIVEOBJ_THIS(iface);
763 return IWebBrowser2_AddRef(WEBBROWSER2(This));
766 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
768 WebBrowser *This = ACTIVEOBJ_THIS(iface);
769 return IWebBrowser2_Release(WEBBROWSER2(This));
772 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
773 HWND *phwnd)
775 WebBrowser *This = ACTIVEOBJ_THIS(iface);
776 return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
779 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
780 BOOL fEnterMode)
782 WebBrowser *This = ACTIVEOBJ_THIS(iface);
783 return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
786 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
787 LPMSG lpmsg)
789 WebBrowser *This = ACTIVEOBJ_THIS(iface);
790 FIXME("(%p)->(%p)\n", This, lpmsg);
791 return E_NOTIMPL;
794 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
795 BOOL fActivate)
797 WebBrowser *This = ACTIVEOBJ_THIS(iface);
798 FIXME("(%p)->(%x)\n", This, fActivate);
799 return E_NOTIMPL;
802 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
803 BOOL fActivate)
805 WebBrowser *This = ACTIVEOBJ_THIS(iface);
806 FIXME("(%p)->(%x)\n", This, fActivate);
807 return E_NOTIMPL;
810 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
811 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
813 WebBrowser *This = ACTIVEOBJ_THIS(iface);
814 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
815 return E_NOTIMPL;
818 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
819 BOOL fEnable)
821 WebBrowser *This = ACTIVEOBJ_THIS(iface);
822 FIXME("(%p)->(%x)\n", This, fEnable);
823 return E_NOTIMPL;
826 #undef ACTIVEOBJ_THIS
828 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
829 InPlaceActiveObject_QueryInterface,
830 InPlaceActiveObject_AddRef,
831 InPlaceActiveObject_Release,
832 InPlaceActiveObject_GetWindow,
833 InPlaceActiveObject_ContextSensitiveHelp,
834 InPlaceActiveObject_TranslateAccelerator,
835 InPlaceActiveObject_OnFrameWindowActivate,
836 InPlaceActiveObject_OnDocWindowActivate,
837 InPlaceActiveObject_ResizeBorder,
838 InPlaceActiveObject_EnableModeless
841 #define OLECMD_THIS(iface) DEFINE_THIS(WebBrowser, OleCommandTarget, iface)
843 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
844 REFIID riid, void **ppv)
846 WebBrowser *This = OLECMD_THIS(iface);
847 return IWebBrowser2_QueryInterface(WEBBROWSER(This), riid, ppv);
850 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
852 WebBrowser *This = OLECMD_THIS(iface);
853 return IWebBrowser2_AddRef(WEBBROWSER(This));
856 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
858 WebBrowser *This = OLECMD_THIS(iface);
859 return IWebBrowser2_Release(WEBBROWSER(This));
862 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
863 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
865 WebBrowser *This = OLECMD_THIS(iface);
866 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
867 pCmdText);
868 return E_NOTIMPL;
871 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
872 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
873 VARIANT *pvaOut)
875 WebBrowser *This = OLECMD_THIS(iface);
876 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
877 nCmdexecopt, pvaIn, pvaOut);
878 return E_NOTIMPL;
881 #undef OLECMD_THIS
883 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
884 WBOleCommandTarget_QueryInterface,
885 WBOleCommandTarget_AddRef,
886 WBOleCommandTarget_Release,
887 WBOleCommandTarget_QueryStatus,
888 WBOleCommandTarget_Exec
891 void WebBrowser_OleObject_Init(WebBrowser *This)
893 This->lpOleObjectVtbl = &OleObjectVtbl;
894 This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
895 This->lpOleControlVtbl = &OleControlVtbl;
896 This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
897 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
899 This->client = NULL;
900 This->inplace = NULL;
901 This->container = NULL;
902 This->frame_hwnd = NULL;
903 This->uiwindow = NULL;
904 This->shell_embedding_hwnd = NULL;
906 memset(&This->pos_rect, 0, sizeof(RECT));
907 memset(&This->clip_rect, 0, sizeof(RECT));
908 memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
910 This->extent.cx = 1323;
911 This->extent.cy = 529;
914 void WebBrowser_OleObject_Destroy(WebBrowser *This)
916 if(This->client)
917 IOleObject_SetClientSite(OLEOBJ(This), NULL);
918 if(This->container)
919 IOleContainer_Release(This->container);
920 if(This->uiwindow)
921 IOleInPlaceUIWindow_Release(This->uiwindow);