Fix some -Wstrict-prototype warnings () -> (void).
[wine] / dlls / mshtml / view.c
1 /*
2  * Copyright 2005-2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "wingdi.h"
30 #include "commctrl.h"
31 #include "ole2.h"
32 #include "resource.h"
33
34 #include "wine/debug.h"
35
36 #include "mshtml_private.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39
40 static const WCHAR wszInternetExplorer_Server[] =
41     {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
42
43 static const WCHAR wszTooltipData[] = {'t','o','o','l','t','i','p','_','d','a','t','a',0};
44
45 static ATOM serverwnd_class = 0;
46
47 typedef struct {
48     HTMLDocument *doc;
49     WNDPROC proc;
50 } tooltip_data;
51
52 static LRESULT WINAPI hidden_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
53 {
54     if(msg > WM_USER)
55         FIXME("(%p %d %x %lx)\n", hwnd, msg, wParam, lParam);
56
57     return DefWindowProcW(hwnd, msg, wParam, lParam);
58 }
59
60 static void create_hidden_window(HTMLDocument *This)
61 {
62     static ATOM hidden_wnd_class = 0;
63     static const WCHAR wszInternetExplorer_Hidden[] = {'I','n','t','e','r','n','e','t',
64             ' ','E','x','p','l','o','r','e','r','_','H','i','d','d','e','n',0};
65
66     if(!hidden_wnd_class) {
67         WNDCLASSEXW wndclass = {
68             sizeof(WNDCLASSEXW), 0,
69             hidden_proc,
70             0, 0, hInst, NULL, NULL, NULL, NULL,
71             wszInternetExplorer_Hidden,
72             NULL
73         };
74
75         hidden_wnd_class = RegisterClassExW(&wndclass);
76     }
77
78     This->hidden_hwnd = CreateWindowExW(0, wszInternetExplorer_Hidden, NULL, WS_POPUP,
79                                         0, 0, 0, 0, NULL, NULL, hInst, This);
80 }
81
82 static void paint_disabled(HWND hwnd) {
83     HDC hdc;
84     PAINTSTRUCT ps;
85     HBRUSH brush;
86     RECT rect;
87     HFONT font;
88     WCHAR wszHTMLDisabled[100];
89
90     LoadStringW(hInst, IDS_HTMLDISABLED, wszHTMLDisabled, sizeof(wszHTMLDisabled)/sizeof(WCHAR));
91
92     font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
93     brush = CreateSolidBrush(RGB(255,255,255));
94     GetClientRect(hwnd, &rect);
95
96     hdc = BeginPaint(hwnd, &ps);
97     SelectObject(hdc, font);
98     SelectObject(hdc, brush);
99     Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
100     DrawTextW(hdc, wszHTMLDisabled,-1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
101     EndPaint(hwnd, &ps);
102
103     DeleteObject(font);
104     DeleteObject(brush);
105 }
106
107 static void activate_gecko(HTMLDocument *This)
108 {
109     TRACE("(%p) %p\n", This, This->nscontainer->window);
110
111     SetParent(This->nscontainer->hwnd, This->hwnd);
112     ShowWindow(This->nscontainer->hwnd, SW_SHOW);
113
114     nsIBaseWindow_SetVisibility(This->nscontainer->window, TRUE);
115     nsIBaseWindow_SetEnabled(This->nscontainer->window, TRUE);
116     nsIWebBrowserFocus_Activate(This->nscontainer->focus);
117 }
118
119 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
120 {
121     HTMLDocument *This;
122
123     static const WCHAR wszTHIS[] = {'T','H','I','S',0};
124
125     if(msg == WM_CREATE) {
126         This = *(HTMLDocument**)lParam;
127         SetPropW(hwnd, wszTHIS, This);
128     }else {
129         This = (HTMLDocument*)GetPropW(hwnd, wszTHIS);
130     }
131
132     switch(msg) {
133     case WM_CREATE:
134         This->hwnd = hwnd;
135         if(This->nscontainer)
136             activate_gecko(This);
137         break;
138     case WM_PAINT:
139         if(!This->nscontainer)
140             paint_disabled(hwnd);
141         break;
142     case WM_SIZE:
143         TRACE("(%p)->(WM_SIZE)\n", This);
144         if(This->nscontainer)
145             SetWindowPos(This->nscontainer->hwnd, NULL, 0, 0, LOWORD(lParam), HIWORD(lParam),
146                     SWP_NOZORDER | SWP_NOACTIVATE);
147     }
148         
149     return DefWindowProcW(hwnd, msg, wParam, lParam);
150 }
151
152 static void register_serverwnd_class(void)
153 {
154     static WNDCLASSEXW wndclass = {
155         sizeof(WNDCLASSEXW),
156         CS_DBLCLKS,
157         serverwnd_proc,
158         0, 0, NULL, NULL, NULL, NULL, NULL,
159         wszInternetExplorer_Server,
160         NULL,
161     };
162     wndclass.hInstance = hInst;
163     serverwnd_class = RegisterClassExW(&wndclass);
164 }
165
166 static HRESULT activate_window(HTMLDocument *This)
167 {
168     IOleInPlaceUIWindow *pIPWnd;
169     IOleInPlaceFrame *pIPFrame;
170     IOleCommandTarget *cmdtrg;
171     RECT posrect, cliprect;
172     OLEINPLACEFRAMEINFO frameinfo;
173     HWND parent_hwnd;
174     HRESULT hres;
175
176     if(!serverwnd_class)
177         register_serverwnd_class();
178
179     hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
180     if(hres != S_OK) {
181         WARN("CanInPlaceActivate returned: %08lx\n", hres);
182         return FAILED(hres) ? hres : E_FAIL;
183     }
184
185     hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo);
186     if(FAILED(hres)) {
187         WARN("GetWindowContext failed: %08lx\n", hres);
188         return hres;
189     }
190
191     if(pIPWnd)
192         IOleInPlaceUIWindow_Release(pIPWnd);
193     TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n",
194             pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom,
195             cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
196             frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
197
198     hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
199     if(FAILED(hres)) {
200         WARN("GetWindow failed: %08lx\n", hres);
201         return hres;
202     }
203
204     TRACE("got parent window %p\n", parent_hwnd);
205
206     if(This->hwnd) {
207         if(GetParent(This->hwnd) != parent_hwnd)
208             SetParent(This->hwnd, parent_hwnd);
209         SetWindowPos(This->hwnd, HWND_TOP,
210                 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
211                 SWP_NOACTIVATE | SWP_SHOWWINDOW);
212     }else {
213         CreateWindowExW(0, wszInternetExplorer_Server, NULL,
214                 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
215                 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
216                 parent_hwnd, NULL, hInst, This);
217
218         TRACE("Created window %p\n", This->hwnd);
219
220         SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
221                 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
222         RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
223         SetFocus(This->hwnd);
224
225         /* NOTE:
226          * Windows implementation calls:
227          * RegisterWindowMessage("MSWHEEL_ROLLMSG");
228          * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
229          */
230     }
231
232     This->in_place_active = TRUE;
233     hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
234     if(FAILED(hres)) {
235         WARN("OnInPlaceActivate failed: %08lx\n", hres);
236         This->in_place_active = FALSE;
237         return hres;
238     }
239
240     hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
241     if(SUCCEEDED(hres)) {
242         VARIANT var;
243
244         IOleInPlaceFrame_SetStatusText(pIPFrame, NULL);
245
246         V_VT(&var) = VT_I4;
247         V_I4(&var) = 0;
248         IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
249                 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
250         IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS, 
251                 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
252
253         IOleCommandTarget_Release(cmdtrg);
254     }
255
256     if(This->frame)
257         IOleInPlaceFrame_Release(This->frame);
258     This->frame = pIPFrame;
259
260     This->window_active = TRUE;
261
262     return S_OK;
263 }
264
265 static LRESULT tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
266 {
267     tooltip_data *data = GetPropW(hwnd, wszTooltipData);
268
269     TRACE("%d %p\n", msg, data);
270
271     if(msg == TTM_WINDOWFROMPOINT) {
272         RECT rect;
273         POINT *pt = (POINT*)lParam;
274
275         TRACE("TTM_WINDOWFROMPOINT (%ld,%ld)\n", pt->x, pt->y);
276
277         GetWindowRect(data->doc->hwnd, &rect);
278
279         if(rect.left <= pt->x && pt->x <= rect.right
280            && rect.top <= pt->y && pt->y <= rect.bottom)
281             return (LPARAM)data->doc->hwnd;
282     }
283
284     return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam);
285 }
286
287 static void create_tooltips_window(HTMLDocument *This)
288 {
289     tooltip_data *data = mshtml_alloc(sizeof(*data));
290
291     This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
292             CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);
293
294     data->doc = This;
295     data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);
296
297     SetPropW(This->tooltips_hwnd, wszTooltipData, data);
298
299     SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);
300
301     SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
302                  SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
303
304 }
305
306 void show_tooltip(HTMLDocument *This, DWORD x, DWORD y, LPCWSTR text)
307 {
308     TTTOOLINFOW toolinfo = {
309         sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
310         {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */
311         NULL, (LPWSTR)text, 0};
312     MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}};
313
314     TRACE("(%p)->(%ld %ld %s)\n", This, x, y, debugstr_w(text));
315
316     if(!This->tooltips_hwnd)
317         create_tooltips_window(This);
318
319     SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
320     SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0);
321     SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg);
322 }
323
324 void hide_tooltip(HTMLDocument *This)
325 {
326     TTTOOLINFOW toolinfo = {
327         sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
328         {0,0,0,0}, NULL, NULL, 0};
329
330     TRACE("(%p)\n", This);
331
332     SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo);
333     SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0);
334 }
335
336 /**********************************************************
337  * IOleDocumentView implementation
338  */
339
340 #define DOCVIEW_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocumentView, iface)
341
342 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
343 {
344     HTMLDocument *This = DOCVIEW_THIS(iface);
345     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
346 }
347
348 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
349 {
350     HTMLDocument *This = DOCVIEW_THIS(iface);
351     return IHTMLDocument2_AddRef(HTMLDOC(This));
352 }
353
354 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
355 {
356     HTMLDocument *This = DOCVIEW_THIS(iface);
357     return IHTMLDocument2_Release(HTMLDOC(This));
358 }
359
360 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
361 {
362     HTMLDocument *This = DOCVIEW_THIS(iface);
363     TRACE("(%p)->(%p)\n", This, pIPSite);
364
365     if(pIPSite)
366         IOleInPlaceSite_AddRef(pIPSite);
367
368     if(This->ipsite)
369         IOleInPlaceSite_Release(This->ipsite);
370
371     This->ipsite = pIPSite;
372     return S_OK;
373 }
374
375 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
376 {
377     HTMLDocument *This = DOCVIEW_THIS(iface);
378     TRACE("(%p)->(%p)\n", This, ppIPSite);
379
380     if(!ppIPSite)
381         return E_INVALIDARG;
382
383     if(This->ipsite)
384         IOleInPlaceSite_AddRef(This->ipsite);
385
386     *ppIPSite = This->ipsite;
387     return S_OK;
388 }
389
390 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
391 {
392     HTMLDocument *This = DOCVIEW_THIS(iface);
393     TRACE("(%p)->(%p)\n", This, ppunk);
394
395     if(!ppunk)
396         return E_INVALIDARG;
397
398     IHTMLDocument2_AddRef(HTMLDOC(This));
399     *ppunk = (IUnknown*)HTMLDOC(This);
400     return S_OK;
401 }
402
403 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
404 {
405     HTMLDocument *This = DOCVIEW_THIS(iface);
406     RECT rect;
407
408     TRACE("(%p)->(%p)\n", This, prcView);
409
410     if(!prcView)
411         return E_INVALIDARG;
412
413     if(This->hwnd) {
414         GetClientRect(This->hwnd, &rect);
415         if(memcmp(prcView, &rect, sizeof(RECT))) {
416             InvalidateRect(This->hwnd,NULL,TRUE);
417             SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
418                     prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
419         }
420     }
421     
422     return S_OK;
423 }
424
425 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
426 {
427     HTMLDocument *This = DOCVIEW_THIS(iface);
428
429     TRACE("(%p)->(%p)\n", This, prcView);
430
431     if(!prcView)
432         return E_INVALIDARG;
433
434     GetClientRect(This->hwnd, prcView);
435     return S_OK;
436 }
437
438 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
439                         LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
440 {
441     HTMLDocument *This = DOCVIEW_THIS(iface);
442     FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
443     return E_NOTIMPL;
444 }
445
446 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
447 {
448     HTMLDocument *This = DOCVIEW_THIS(iface);
449     HRESULT hres;
450
451     TRACE("(%p)->(%x)\n", This, fShow);
452
453     if(fShow) {
454         if(!This->ui_active) {
455             hres = activate_window(This);
456             if(FAILED(hres))
457                 return hres;
458         }
459         ShowWindow(This->hwnd, SW_SHOW);
460     }else {
461         ShowWindow(This->hwnd, SW_HIDE);
462     }
463
464     return S_OK;
465 }
466
467 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
468 {
469     HTMLDocument *This = DOCVIEW_THIS(iface);
470     HRESULT hres;
471
472     TRACE("(%p)->(%x)\n", This, fUIActivate);
473
474     if(!This->ipsite) {
475         FIXME("This->ipsite = NULL\n");
476         return E_FAIL;
477     }
478
479     if(fUIActivate) {
480         if(This->ui_active)
481             return S_OK;
482
483         if(!This->window_active) {
484             hres = activate_window(This);
485             if(FAILED(hres))
486                 return hres;
487         }
488
489         hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
490         if(SUCCEEDED(hres)) {
491             OLECHAR wszHTMLDocument[30];
492             LoadStringW(hInst, IDS_HTMLDOCUMENT, wszHTMLDocument,
493                     sizeof(wszHTMLDocument)/sizeof(WCHAR));
494             IOleInPlaceFrame_SetActiveObject(This->frame, ACTOBJ(This), wszHTMLDocument);
495         }else {
496             FIXME("OnUIActivate failed: %08lx\n", hres);
497             IOleInPlaceFrame_Release(This->frame);
498             This->frame = NULL;
499             This->ui_active = FALSE;
500             return hres;
501         }
502
503         hres = IDocHostUIHandler_ShowUI(This->hostui, 0, ACTOBJ(This), CMDTARGET(This),
504                 This->frame, NULL);
505         if(FAILED(hres))
506             IDocHostUIHandler_HideUI(This->hostui);
507
508         This->ui_active = TRUE;
509     }else {
510         This->window_active = FALSE;
511         if(This->ui_active) {
512             This->ui_active = FALSE;
513             if(This->frame)
514                 IOleInPlaceFrame_SetActiveObject(This->frame, NULL, NULL);
515             if(This->hostui)
516                 IDocHostUIHandler_HideUI(This->hostui);
517             if(This->ipsite)
518                 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
519         }
520     }
521     return S_OK;
522 }
523
524 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
525 {
526     HTMLDocument *This = DOCVIEW_THIS(iface);
527     FIXME("(%p)\n", This);
528     return E_NOTIMPL;
529 }
530
531 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
532 {
533     HTMLDocument *This = DOCVIEW_THIS(iface);
534     TRACE("(%p)->(%lx)\n", This, dwReserved);
535
536     if(dwReserved)
537         WARN("dwReserved = %ld\n", dwReserved);
538
539     /* NOTE:
540      * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
541      * QueryInterface(IID_IOleControlSite) and KillTimer
542      */
543
544     IOleDocumentView_Show(iface, FALSE);
545
546     return S_OK;
547 }
548
549 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
550 {
551     HTMLDocument *This = DOCVIEW_THIS(iface);
552     FIXME("(%p)->(%p)\n", This, pstm);
553     return E_NOTIMPL;
554 }
555
556 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
557 {
558     HTMLDocument *This = DOCVIEW_THIS(iface);
559     FIXME("(%p)->(%p)\n", This, pstm);
560     return E_NOTIMPL;
561 }
562
563 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
564                                         IOleDocumentView **ppViewNew)
565 {
566     HTMLDocument *This = DOCVIEW_THIS(iface);
567     FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
568     return E_NOTIMPL;
569 }
570
571 #undef DOCVIEW_THIS
572
573 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
574     OleDocumentView_QueryInterface,
575     OleDocumentView_AddRef,
576     OleDocumentView_Release,
577     OleDocumentView_SetInPlaceSite,
578     OleDocumentView_GetInPlaceSite,
579     OleDocumentView_GetDocument,
580     OleDocumentView_SetRect,
581     OleDocumentView_GetRect,
582     OleDocumentView_SetRectComplex,
583     OleDocumentView_Show,
584     OleDocumentView_UIActivate,
585     OleDocumentView_Open,
586     OleDocumentView_CloseView,
587     OleDocumentView_SaveViewState,
588     OleDocumentView_ApplyViewState,
589     OleDocumentView_Clone
590 };
591
592 /**********************************************************
593  * IViewObject implementation
594  */
595
596 #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface)
597
598 static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject)
599 {
600     HTMLDocument *This = VIEWOBJ_THIS(iface);
601     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
602 }
603
604 static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
605 {
606     HTMLDocument *This = VIEWOBJ_THIS(iface);
607     return IHTMLDocument2_AddRef(HTMLDOC(This));
608 }
609
610 static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
611 {
612     HTMLDocument *This = VIEWOBJ_THIS(iface);
613     return IHTMLDocument2_Release(HTMLDOC(This));
614 }
615
616 static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
617         DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
618         LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
619 {
620     HTMLDocument *This = VIEWOBJ_THIS(iface);
621     FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
622             ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
623     return E_NOTIMPL;
624 }
625
626 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
627         DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
628 {
629     HTMLDocument *This = VIEWOBJ_THIS(iface);
630     FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
631     return E_NOTIMPL;
632 }
633
634 static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
635         void *pvAspect, DWORD *pdwFreeze)
636 {
637     HTMLDocument *This = VIEWOBJ_THIS(iface);
638     FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
639     return E_NOTIMPL;
640 }
641
642 static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
643 {
644     HTMLDocument *This = VIEWOBJ_THIS(iface);
645     FIXME("(%p)->(%ld)\n", This, dwFreeze);
646     return E_NOTIMPL;
647 }
648
649 static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
650 {
651     HTMLDocument *This = VIEWOBJ_THIS(iface);
652     FIXME("(%p)->(%ld %ld %p)\n", This, aspects, advf, pAdvSink);
653     return E_NOTIMPL;
654 }
655
656 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
657 {
658     HTMLDocument *This = VIEWOBJ_THIS(iface);
659     FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
660     return E_NOTIMPL;
661 }
662
663 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
664                                 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
665 {
666     HTMLDocument *This = VIEWOBJ_THIS(iface);
667     FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
668     return E_NOTIMPL;
669 }
670
671 #undef VIEWOBJ_THIS
672
673 static const IViewObject2Vtbl ViewObjectVtbl = {
674     ViewObject_QueryInterface,
675     ViewObject_AddRef,
676     ViewObject_Release,
677     ViewObject_Draw,
678     ViewObject_GetColorSet,
679     ViewObject_Freeze,
680     ViewObject_Unfreeze,
681     ViewObject_SetAdvise,
682     ViewObject_GetAdvise,
683     ViewObject_GetExtent
684 };
685
686 void HTMLDocument_View_Init(HTMLDocument *This)
687 {
688     This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
689     This->lpViewObject2Vtbl = &ViewObjectVtbl;
690
691     This->ipsite = NULL;
692     This->frame = NULL;
693     This->hwnd = NULL;
694     This->tooltips_hwnd = NULL;
695
696     This->in_place_active = FALSE;
697     This->ui_active = FALSE;
698     This->window_active = FALSE;
699
700     create_hidden_window(This);
701 }