- Fix crashes in calls to ScmAssignNewTag.
[reactos.git] / reactos / lib / shdocvw / oleobject.c
1 /*
2 * Implementation of IOleObject interfaces for WebBrowser control
3 *
4 * - IOleObject
5 * - IOleInPlaceObject
6 * - IOleControl
7 *
8 * Copyright 2001 John R. Sheets (for CodeWeavers)
9 * Copyright 2005 Jacek Caban
10 *
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.
15 *
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.
20 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26 #include <string.h>
27 #include "wine/debug.h"
28 #include "shdocvw.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
31
32 static ATOM shell_embedding_atom = 0;
33
34 static LRESULT resize_window(WebBrowser *This, LONG width, LONG height)
35 {
36 if(This->doc_view_hwnd)
37 SetWindowPos(This->doc_view_hwnd, NULL, 0, 0, width, height,
38 SWP_NOZORDER | SWP_NOACTIVATE);
39
40 return 0;
41 }
42
43 static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
44 {
45 WebBrowser *This;
46
47 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
48
49 if(msg == WM_CREATE) {
50 This = *(WebBrowser**)lParam;
51 SetPropW(hwnd, wszTHIS, This);
52 }else {
53 This = GetPropW(hwnd, wszTHIS);
54 }
55
56 switch(msg) {
57 case WM_SIZE:
58 return resize_window(This, LOWORD(lParam), HIWORD(lParam));
59 }
60
61 return DefWindowProcA(hwnd, msg, wParam, lParam);
62 }
63
64 static void create_shell_embedding_hwnd(WebBrowser *This)
65 {
66 IOleInPlaceSite *inplace;
67 HWND parent = NULL;
68 HRESULT hres;
69
70 static const WCHAR wszShellEmbedding[] =
71 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
72
73 if(!shell_embedding_atom) {
74 static WNDCLASSEXW wndclass = {
75 sizeof(wndclass),
76 CS_DBLCLKS,
77 shell_embedding_proc,
78 0, 0 /* native uses 8 */, NULL, NULL, NULL,
79 (HBRUSH)COLOR_WINDOWFRAME, NULL,
80 wszShellEmbedding,
81 NULL
82 };
83 wndclass.hInstance = shdocvw_hinstance;
84
85 RegisterClassExW(&wndclass);
86 }
87
88 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace);
89 if(SUCCEEDED(hres)) {
90 IOleInPlaceSite_GetWindow(inplace, &parent);
91 IOleInPlaceSite_Release(inplace);
92 }
93
94 This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, wszShellEmbedding,
95 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
96 0, 0, 0, 0, parent,
97 NULL, shdocvw_hinstance, This);
98 }
99
100 /**********************************************************************
101 * Implement the IOleObject interface for the WebBrowser control
102 */
103
104 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
105
106 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
107 {
108 WebBrowser *This = OLEOBJ_THIS(iface);
109 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
110 }
111
112 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
113 {
114 WebBrowser *This = OLEOBJ_THIS(iface);
115 return IWebBrowser_AddRef(WEBBROWSER(This));
116 }
117
118 static ULONG WINAPI OleObject_Release(IOleObject *iface)
119 {
120 WebBrowser *This = OLEOBJ_THIS(iface);
121 return IWebBrowser_Release(WEBBROWSER(This));
122 }
123
124 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
125 {
126 WebBrowser *This = OLEOBJ_THIS(iface);
127
128 TRACE("(%p)->(%p)\n", This, pClientSite);
129
130 if(This->client == pClientSite)
131 return S_OK;
132
133 if(This->doc_view_hwnd)
134 DestroyWindow(This->doc_view_hwnd);
135 if(This->shell_embedding_hwnd)
136 DestroyWindow(This->shell_embedding_hwnd);
137
138 if(This->client)
139 IOleClientSite_Release(This->client);
140
141 This->client = pClientSite;
142 if(!pClientSite)
143 return S_OK;
144
145 IOleClientSite_AddRef(pClientSite);
146
147 create_shell_embedding_hwnd(This);
148
149 return S_OK;
150 }
151
152 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
153 {
154 WebBrowser *This = OLEOBJ_THIS(iface);
155
156 TRACE("(%p)->(%p)\n", This, ppClientSite);
157
158 if(!ppClientSite)
159 return E_INVALIDARG;
160
161 if(This->client)
162 IOleClientSite_AddRef(This->client);
163 *ppClientSite = This->client;
164
165 return S_OK;
166 }
167
168 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
169 LPCOLESTR szContainerObj)
170 {
171 WebBrowser *This = OLEOBJ_THIS(iface);
172 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
173 return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
177 {
178 WebBrowser *This = OLEOBJ_THIS(iface);
179 FIXME("(%p)->(%ld)\n", This, dwSaveOption);
180 return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
184 {
185 WebBrowser *This = OLEOBJ_THIS(iface);
186 FIXME("(%p)->(%ld, %p)\n", This, dwWhichMoniker, pmk);
187 return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
191 DWORD dwWhichMoniker, LPMONIKER *ppmk)
192 {
193 WebBrowser *This = OLEOBJ_THIS(iface);
194 FIXME("(%p)->(%ld, %ld, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
195 return E_NOTIMPL;
196 }
197
198 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
199 BOOL fCreation, DWORD dwReserved)
200 {
201 WebBrowser *This = OLEOBJ_THIS(iface);
202 FIXME("(%p)->(%p, %d, %ld)\n", This, pDataObject, fCreation, dwReserved);
203 return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
207 LPDATAOBJECT *ppDataObject)
208 {
209 WebBrowser *This = OLEOBJ_THIS(iface);
210 FIXME("(%p)->(%ld, %p)\n", This, dwReserved, ppDataObject);
211 return E_NOTIMPL;
212 }
213
214 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
215 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
216 {
217 WebBrowser *This = OLEOBJ_THIS(iface);
218 HRESULT hres;
219
220 static const WCHAR wszitem[] = {'i','t','e','m',0};
221
222 TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
223 lprcPosRect);
224
225 switch (iVerb)
226 {
227 case OLEIVERB_SHOW:
228 case OLEIVERB_INPLACEACTIVATE: {
229 IOleInPlaceSite *inplace;
230
231 TRACE("OLEIVERB_INPLACEACTIVATE\n");
232
233 if(!pActiveSite)
234 return E_INVALIDARG;
235
236 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleInPlaceSite, (void**)&inplace);
237 if(FAILED(hres)) {
238 WARN("Could not get IOleInPlaceSite\n");
239 return hres;
240 }
241
242 hres = IOleInPlaceSite_CanInPlaceActivate(inplace);
243 if(hres != S_OK) {
244 WARN("CanInPlaceActivate returned: %08lx\n", hres);
245 IOleInPlaceSite_Release(inplace);
246 return E_FAIL;
247 }
248
249 hres = IOleInPlaceSite_GetWindow(inplace, &This->iphwnd);
250 if(FAILED(hres))
251 This->iphwnd = hwndParent;
252
253 IOleInPlaceSite_OnInPlaceActivate(inplace);
254
255 IOleInPlaceSite_GetWindowContext(inplace, &This->frame, &This->uiwindow,
256 &This->pos_rect, &This->clip_rect,
257 &This->frameinfo);
258
259
260 if(iVerb == OLEIVERB_INPLACEACTIVATE)
261 IOleInPlaceSite_Release(inplace);
262
263 SetWindowPos(This->shell_embedding_hwnd, NULL,
264 This->pos_rect.left, This->pos_rect.top,
265 This->pos_rect.right-This->pos_rect.left,
266 This->pos_rect.bottom-This->pos_rect.top,
267 SWP_NOZORDER | SWP_SHOWWINDOW);
268
269 if(This->client) {
270 IOleClientSite_ShowObject(This->client);
271 IOleClientSite_GetContainer(This->client, &This->container);
272 }
273
274 if(This->frame)
275 IOleInPlaceFrame_GetWindow(This->frame, &This->frame_hwnd);
276
277 if(iVerb == OLEIVERB_INPLACEACTIVATE)
278 return S_OK;
279
280 TRACE("OLEIVERB_SHOW\n");
281
282 IOleInPlaceSite_OnUIActivate(inplace);
283 IOleInPlaceSite_Release(inplace);
284
285 IOleInPlaceFrame_SetActiveObject(This->frame, ACTIVEOBJ(This), wszitem);
286
287 /* TODO:
288 * IOleInPlaceFrmae_SetMenu
289 */
290
291 return S_OK;
292 }
293 default:
294 FIXME("stub for %ld\n", iVerb);
295 break;
296 }
297
298 return E_NOTIMPL;
299 }
300
301 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
302 {
303 WebBrowser *This = OLEOBJ_THIS(iface);
304 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
305 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
306 }
307
308 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
309 {
310 WebBrowser *This = OLEOBJ_THIS(iface);
311 FIXME("(%p)\n", This);
312 return E_NOTIMPL;
313 }
314
315 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
316 {
317 WebBrowser *This = OLEOBJ_THIS(iface);
318 FIXME("(%p)\n", This);
319 return E_NOTIMPL;
320 }
321
322 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
323 {
324 WebBrowser *This = OLEOBJ_THIS(iface);
325 FIXME("(%p)->(%p)\n", This, pClsid);
326 return E_NOTIMPL;
327 }
328
329 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
330 LPOLESTR* pszUserType)
331 {
332 WebBrowser *This = OLEOBJ_THIS(iface);
333 TRACE("(%p, %ld, %p)\n", This, dwFormOfType, pszUserType);
334 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
335 }
336
337 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
338 {
339 WebBrowser *This = OLEOBJ_THIS(iface);
340 FIXME("(%p)->(%lx %p)\n", This, dwDrawAspect, psizel);
341 return E_NOTIMPL;
342 }
343
344 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
345 {
346 WebBrowser *This = OLEOBJ_THIS(iface);
347 FIXME("(%p)->(%lx, %p)\n", This, dwDrawAspect, psizel);
348 return E_NOTIMPL;
349 }
350
351 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
352 DWORD* pdwConnection)
353 {
354 WebBrowser *This = OLEOBJ_THIS(iface);
355 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
356 return E_NOTIMPL;
357 }
358
359 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
360 {
361 WebBrowser *This = OLEOBJ_THIS(iface);
362 FIXME("(%p)->(%ld)\n", This, dwConnection);
363 return E_NOTIMPL;
364 }
365
366 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
367 {
368 WebBrowser *This = OLEOBJ_THIS(iface);
369 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
370 return S_OK;
371 }
372
373 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
374 {
375 WebBrowser *This = OLEOBJ_THIS(iface);
376 HRESULT hres;
377
378 TRACE("(%p)->(%lx, %p)\n", This, dwAspect, pdwStatus);
379
380 hres = OleRegGetMiscStatus(&CLSID_WebBrowser, dwAspect, pdwStatus);
381
382 if (FAILED(hres))
383 *pdwStatus = 0;
384
385 return S_OK;
386 }
387
388 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
389 {
390 WebBrowser *This = OLEOBJ_THIS(iface);
391 FIXME("(%p)->(%p)\n", This, pLogpal);
392 return E_NOTIMPL;
393 }
394
395 #undef OLEOBJ_THIS
396
397 static const IOleObjectVtbl OleObjectVtbl =
398 {
399 OleObject_QueryInterface,
400 OleObject_AddRef,
401 OleObject_Release,
402 OleObject_SetClientSite,
403 OleObject_GetClientSite,
404 OleObject_SetHostNames,
405 OleObject_Close,
406 OleObject_SetMoniker,
407 OleObject_GetMoniker,
408 OleObject_InitFromData,
409 OleObject_GetClipboardData,
410 OleObject_DoVerb,
411 OleObject_EnumVerbs,
412 OleObject_Update,
413 OleObject_IsUpToDate,
414 OleObject_GetUserClassID,
415 OleObject_GetUserType,
416 OleObject_SetExtent,
417 OleObject_GetExtent,
418 OleObject_Advise,
419 OleObject_Unadvise,
420 OleObject_EnumAdvise,
421 OleObject_GetMiscStatus,
422 OleObject_SetColorScheme
423 };
424
425 /**********************************************************************
426 * Implement the IOleInPlaceObject interface
427 */
428
429 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
430
431 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
432 REFIID riid, LPVOID *ppobj)
433 {
434 WebBrowser *This = INPLACEOBJ_THIS(iface);
435 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
436 }
437
438 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
439 {
440 WebBrowser *This = INPLACEOBJ_THIS(iface);
441 return IWebBrowser_AddRef(WEBBROWSER(This));
442 }
443
444 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
445 {
446 WebBrowser *This = INPLACEOBJ_THIS(iface);
447 return IWebBrowser_Release(WEBBROWSER(This));
448 }
449
450 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
451 {
452 WebBrowser *This = INPLACEOBJ_THIS(iface);
453
454 FIXME("(%p)->(%p)\n", This, phwnd);
455
456 #if 0
457 /* Create a fake window to fool MFC into believing that we actually
458 * have an implemented browser control. Avoids the assertion.
459 */
460 HWND hwnd;
461 hwnd = CreateWindowA("BUTTON", "Web Control",
462 WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
463 CW_USEDEFAULT, CW_USEDEFAULT, 600,
464 400, NULL, NULL, NULL, NULL);
465
466 *phwnd = hwnd;
467 TRACE ("Returning hwnd = %d\n", hwnd);
468 #endif
469
470 return S_OK;
471 }
472
473 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
474 BOOL fEnterMode)
475 {
476 WebBrowser *This = INPLACEOBJ_THIS(iface);
477 FIXME("(%p)->(%x)\n", This, fEnterMode);
478 return E_NOTIMPL;
479 }
480
481 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
482 {
483 WebBrowser *This = INPLACEOBJ_THIS(iface);
484 FIXME("(%p)\n", This);
485 return E_NOTIMPL;
486 }
487
488 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
489 {
490 WebBrowser *This = INPLACEOBJ_THIS(iface);
491 FIXME("(%p)\n", This);
492 return E_NOTIMPL;
493 }
494
495 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
496 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
497 {
498 WebBrowser *This = INPLACEOBJ_THIS(iface);
499
500 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
501
502 if(This->shell_embedding_hwnd) {
503 SetWindowPos(This->shell_embedding_hwnd, NULL,
504 lprcPosRect->left, lprcPosRect->top,
505 lprcPosRect->right-lprcPosRect->left,
506 lprcPosRect->bottom-lprcPosRect->top,
507 SWP_NOZORDER | SWP_NOACTIVATE);
508 }
509
510 return S_OK;
511 }
512
513 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
514 {
515 WebBrowser *This = INPLACEOBJ_THIS(iface);
516 FIXME("(%p)\n", This);
517 return E_NOTIMPL;
518 }
519
520 #undef INPLACEOBJ_THIS
521
522 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
523 {
524 OleInPlaceObject_QueryInterface,
525 OleInPlaceObject_AddRef,
526 OleInPlaceObject_Release,
527 OleInPlaceObject_GetWindow,
528 OleInPlaceObject_ContextSensitiveHelp,
529 OleInPlaceObject_InPlaceDeactivate,
530 OleInPlaceObject_UIDeactivate,
531 OleInPlaceObject_SetObjectRects,
532 OleInPlaceObject_ReactivateAndUndo
533 };
534
535 /**********************************************************************
536 * Implement the IOleControl interface
537 */
538
539 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
540
541 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
542 REFIID riid, LPVOID *ppobj)
543 {
544 WebBrowser *This = CONTROL_THIS(iface);
545 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
546 }
547
548 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
549 {
550 WebBrowser *This = CONTROL_THIS(iface);
551 return IWebBrowser_AddRef(WEBBROWSER(This));
552 }
553
554 static ULONG WINAPI OleControl_Release(IOleControl *iface)
555 {
556 WebBrowser *This = CONTROL_THIS(iface);
557 return IWebBrowser_Release(WEBBROWSER(This));
558 }
559
560 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
561 {
562 WebBrowser *This = CONTROL_THIS(iface);
563 FIXME("(%p)->(%p)\n", This, pCI);
564 return E_NOTIMPL;
565 }
566
567 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
568 {
569 WebBrowser *This = CONTROL_THIS(iface);
570 FIXME("(%p)->(%p)\n", This, pMsg);
571 return E_NOTIMPL;
572 }
573
574 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
575 {
576 WebBrowser *This = CONTROL_THIS(iface);
577 FIXME("(%p)->(%ld)\n", This, dispID);
578 return E_NOTIMPL;
579 }
580
581 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
582 {
583 WebBrowser *This = CONTROL_THIS(iface);
584 FIXME("(%p)->(%x)\n", This, bFreeze);
585 return E_NOTIMPL;
586 }
587
588 #undef CONTROL_THIS
589
590 static const IOleControlVtbl OleControlVtbl =
591 {
592 OleControl_QueryInterface,
593 OleControl_AddRef,
594 OleControl_Release,
595 OleControl_GetControlInfo,
596 OleControl_OnMnemonic,
597 OleControl_OnAmbientPropertyChange,
598 OleControl_FreezeEvents
599 };
600
601 #define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
602
603 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
604 REFIID riid, void **ppv)
605 {
606 WebBrowser *This = ACTIVEOBJ_THIS(iface);
607 return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
608 }
609
610 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
611 {
612 WebBrowser *This = ACTIVEOBJ_THIS(iface);
613 return IWebBrowser2_AddRef(WEBBROWSER2(This));
614 }
615
616 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
617 {
618 WebBrowser *This = ACTIVEOBJ_THIS(iface);
619 return IWebBrowser2_Release(WEBBROWSER2(This));
620 }
621
622 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
623 HWND *phwnd)
624 {
625 WebBrowser *This = ACTIVEOBJ_THIS(iface);
626 return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
627 }
628
629 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
630 BOOL fEnterMode)
631 {
632 WebBrowser *This = ACTIVEOBJ_THIS(iface);
633 return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
634 }
635
636 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
637 LPMSG lpmsg)
638 {
639 WebBrowser *This = ACTIVEOBJ_THIS(iface);
640 FIXME("(%p)->(%p)\n", This, lpmsg);
641 return E_NOTIMPL;
642 }
643
644 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
645 BOOL fActivate)
646 {
647 WebBrowser *This = ACTIVEOBJ_THIS(iface);
648 FIXME("(%p)->(%x)\n", This, fActivate);
649 return E_NOTIMPL;
650 }
651
652 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
653 BOOL fActivate)
654 {
655 WebBrowser *This = ACTIVEOBJ_THIS(iface);
656 FIXME("(%p)->(%x)\n", This, fActivate);
657 return E_NOTIMPL;
658 }
659
660 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
661 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
662 {
663 WebBrowser *This = ACTIVEOBJ_THIS(iface);
664 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
665 return E_NOTIMPL;
666 }
667
668 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
669 BOOL fEnable)
670 {
671 WebBrowser *This = ACTIVEOBJ_THIS(iface);
672 FIXME("(%p)->(%x)\n", This, fEnable);
673 return E_NOTIMPL;
674 }
675
676 #undef ACTIVEOBJ_THIS
677
678 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
679 InPlaceActiveObject_QueryInterface,
680 InPlaceActiveObject_AddRef,
681 InPlaceActiveObject_Release,
682 InPlaceActiveObject_GetWindow,
683 InPlaceActiveObject_ContextSensitiveHelp,
684 InPlaceActiveObject_TranslateAccelerator,
685 InPlaceActiveObject_OnFrameWindowActivate,
686 InPlaceActiveObject_OnDocWindowActivate,
687 InPlaceActiveObject_ResizeBorder,
688 InPlaceActiveObject_EnableModeless
689 };
690
691 void WebBrowser_OleObject_Init(WebBrowser *This)
692 {
693 This->lpOleObjectVtbl = &OleObjectVtbl;
694 This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
695 This->lpOleControlVtbl = &OleControlVtbl;
696 This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
697
698 This->client = NULL;
699 This->container = NULL;
700 This->iphwnd = NULL;
701 This->frame_hwnd = NULL;
702 This->frame = NULL;
703 This->uiwindow = NULL;
704 This->shell_embedding_hwnd = NULL;
705
706 memset(&This->pos_rect, 0, sizeof(RECT));
707 memset(&This->clip_rect, 0, sizeof(RECT));
708 memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
709 }
710
711 void WebBrowser_OleObject_Destroy(WebBrowser *This)
712 {
713 if(This->client)
714 IOleObject_SetClientSite(OLEOBJ(This), NULL);
715 if(This->container)
716 IOleContainer_Release(This->container);
717 if(This->frame)
718 IOleInPlaceFrame_Release(This->frame);
719 if(This->uiwindow)
720 IOleInPlaceUIWindow_Release(This->uiwindow);
721 }