mshtml: Added IHTMLWindow2::onload property.
[wine.git] / dlls / mshtml / htmlwindow.c
blob91b56f07682c16291a81003d498547736c4a1887
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
33 #include "resource.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 static struct list window_list = LIST_INIT(window_list);
39 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
41 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
43 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
45 *ppv = NULL;
47 if(IsEqualGUID(&IID_IUnknown, riid)) {
48 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
49 *ppv = HTMLWINDOW2(This);
50 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
51 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
52 *ppv = HTMLWINDOW2(This);
53 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
54 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
55 *ppv = DISPATCHEX(This);
56 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
57 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
58 *ppv = HTMLWINDOW2(This);
59 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
60 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
61 *ppv = HTMLWINDOW2(This);
62 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
63 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
64 *ppv = HTMLWINDOW3(This);
65 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
66 return *ppv ? S_OK : E_NOINTERFACE;
69 if(*ppv) {
70 IUnknown_AddRef((IUnknown*)*ppv);
71 return S_OK;
74 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
75 return E_NOINTERFACE;
78 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
80 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
81 LONG ref = InterlockedIncrement(&This->ref);
83 TRACE("(%p) ref=%d\n", This, ref);
85 return ref;
88 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
90 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
91 LONG ref = InterlockedDecrement(&This->ref);
93 TRACE("(%p) ref=%d\n", This, ref);
95 if(!ref) {
96 if(This->event_target)
97 release_event_target(This->event_target);
98 list_remove(&This->entry);
99 release_dispex(&This->dispex);
100 heap_free(This);
103 return ref;
106 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
108 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
110 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
113 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
114 LCID lcid, ITypeInfo **ppTInfo)
116 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
118 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
121 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
122 LPOLESTR *rgszNames, UINT cNames,
123 LCID lcid, DISPID *rgDispId)
125 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
127 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
130 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
131 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
132 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
134 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
136 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
137 pVarResult, pExcepInfo, puArgErr);
140 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
142 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
143 FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
149 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
150 FIXME("(%p)->(%p)\n", This, p);
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
156 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
157 FIXME("(%p)->(%p)\n", This, p);
158 return E_NOTIMPL;
161 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
163 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
164 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
165 return E_NOTIMPL;
168 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
170 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
171 FIXME("(%p)->(%p)\n", This, p);
172 return E_NOTIMPL;
175 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
177 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
178 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
179 return E_NOTIMPL;
182 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
184 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
185 FIXME("(%p)->(%p)\n", This, p);
186 return E_NOTIMPL;
189 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
190 LONG msec, VARIANT *language, LONG *timerID)
192 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
193 VARIANT expr_var;
195 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
197 V_VT(&expr_var) = VT_BSTR;
198 V_BSTR(&expr_var) = expression;
200 return IHTMLWindow3_setTimeout(HTMLWINDOW3(This), &expr_var, msec, language, timerID);
203 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
205 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
207 TRACE("(%p)->(%d)\n", This, timerID);
209 return clear_task_timer(This->doc, FALSE, timerID);
212 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
214 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
215 WCHAR wszTitle[100];
217 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
219 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
220 sizeof(wszTitle)/sizeof(WCHAR))) {
221 WARN("Could not load message box title: %d\n", GetLastError());
222 return S_OK;
225 MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
226 return S_OK;
229 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
230 VARIANT_BOOL *confirmed)
232 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
233 WCHAR wszTitle[100];
235 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
237 if(!confirmed) return E_INVALIDARG;
239 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
240 sizeof(wszTitle)/sizeof(WCHAR))) {
241 WARN("Could not load message box title: %d\n", GetLastError());
242 *confirmed = VARIANT_TRUE;
243 return S_OK;
246 if(MessageBoxW(This->doc->hwnd, message, wszTitle,
247 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
248 *confirmed = VARIANT_TRUE;
249 else *confirmed = VARIANT_FALSE;
251 return S_OK;
254 typedef struct
256 BSTR message;
257 BSTR dststr;
258 VARIANT *textdata;
259 }prompt_arg;
261 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
262 WPARAM wparam, LPARAM lparam)
264 switch(msg)
266 case WM_INITDIALOG:
268 prompt_arg *arg = (prompt_arg*)lparam;
269 WCHAR wszTitle[100];
271 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
272 sizeof(wszTitle)/sizeof(WCHAR))) {
273 WARN("Could not load message box title: %d\n", GetLastError());
274 EndDialog(hwnd, wparam);
275 return FALSE;
278 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
279 SetWindowTextW(hwnd, wszTitle);
280 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
281 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
282 return FALSE;
284 case WM_COMMAND:
285 switch(wparam)
287 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
288 EndDialog(hwnd, wparam);
289 return TRUE;
290 case MAKEWPARAM(IDOK, BN_CLICKED):
292 prompt_arg *arg =
293 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
294 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
295 INT len = GetWindowTextLengthW(hwndPrompt);
297 if(!arg->textdata)
299 EndDialog(hwnd, wparam);
300 return TRUE;
303 V_VT(arg->textdata) = VT_BSTR;
304 if(!len && !arg->dststr)
305 V_BSTR(arg->textdata) = NULL;
306 else
308 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
309 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
311 EndDialog(hwnd, wparam);
312 return TRUE;
315 return FALSE;
316 case WM_CLOSE:
317 EndDialog(hwnd, IDCANCEL);
318 return TRUE;
319 default:
320 return FALSE;
324 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
325 BSTR dststr, VARIANT *textdata)
327 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
328 prompt_arg arg;
330 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
332 if(textdata) V_VT(textdata) = VT_NULL;
334 arg.message = message;
335 arg.dststr = dststr;
336 arg.textdata = textdata;
338 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
339 This->doc->hwnd, prompt_dlgproc, (LPARAM)&arg);
340 return S_OK;
343 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
345 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
346 FIXME("(%p)->(%p)\n", This, p);
347 return E_NOTIMPL;
350 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
352 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
354 TRACE("(%p)->(%p)\n", This, p);
356 if(!This->doc) {
357 FIXME("This->doc is NULL\n");
358 return E_FAIL;
361 return IHTMLDocument2_get_location(HTMLDOC(This->doc), p);
364 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
366 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
367 FIXME("(%p)->(%p)\n", This, p);
368 return E_NOTIMPL;
371 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
373 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
374 FIXME("(%p)->()\n", This);
375 return E_NOTIMPL;
378 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
380 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
381 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
382 return E_NOTIMPL;
385 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
387 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
388 FIXME("(%p)->(%p)\n", This, p);
389 return E_NOTIMPL;
392 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
394 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
396 TRACE("(%p)->(%p)\n", This, p);
398 *p = OmNavigator_Create();
399 return S_OK;
402 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
404 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
405 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
406 return E_NOTIMPL;
409 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
411 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
412 FIXME("(%p)->(%p)\n", This, p);
413 return E_NOTIMPL;
416 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
418 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
419 FIXME("(%p)->(%p)\n", This, p);
420 return E_NOTIMPL;
423 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
424 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
426 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
427 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
428 debugstr_w(features), replace, pomWindowResult);
429 return E_NOTIMPL;
432 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
434 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
436 TRACE("(%p)->(%p)\n", This, p);
438 /* FIXME: We should return kind of proxy window here. */
439 IHTMLWindow2_AddRef(HTMLWINDOW2(This));
440 *p = HTMLWINDOW2(This);
441 return S_OK;
444 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
446 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
447 FIXME("(%p)->(%p)\n", This, p);
448 return E_NOTIMPL;
451 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
453 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
455 TRACE("(%p)->(%p)\n", This, p);
457 /* FIXME: We should return kind of proxy window here. */
458 IHTMLWindow2_AddRef(HTMLWINDOW2(This));
459 *p = HTMLWINDOW2(This);
460 return S_OK;
463 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
465 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
466 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
467 return E_NOTIMPL;
470 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
472 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
473 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
474 return E_NOTIMPL;
477 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
479 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
480 FIXME("(%p)->(%p)\n", This, p);
481 return E_NOTIMPL;
484 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
486 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
487 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
488 return E_NOTIMPL;
491 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
493 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
495 return E_NOTIMPL;
498 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
500 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
502 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
504 return set_window_event(This, EVENTID_LOAD, &v);
507 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
509 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
511 TRACE("(%p)->(%p)\n", This, p);
513 return get_window_event(This, EVENTID_LOAD, p);
516 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
518 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
520 TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
522 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
525 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
527 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
529 TRACE("(%p)->(%p)\n", This, p);
531 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
534 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
536 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
537 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
538 return E_NOTIMPL;
541 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
543 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
544 FIXME("(%p)->(%p)\n", This, p);
545 return E_NOTIMPL;
548 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
550 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
551 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
552 return E_NOTIMPL;
555 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
557 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, p);
559 return E_NOTIMPL;
562 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
564 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
565 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
566 return E_NOTIMPL;
569 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
571 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
572 FIXME("(%p)->(%p)\n", This, p);
573 return E_NOTIMPL;
576 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
578 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
579 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
580 return E_NOTIMPL;
583 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
585 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
586 FIXME("(%p)->(%p)\n", This, p);
587 return E_NOTIMPL;
590 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
592 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
593 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
594 return E_NOTIMPL;
597 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
599 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
600 FIXME("(%p)->(%p)\n", This, p);
601 return E_NOTIMPL;
604 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
606 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
608 TRACE("(%p)->(%p)\n", This, p);
610 if(This->doc) {
611 /* FIXME: We should return a wrapper object here */
612 *p = HTMLDOC(This->doc);
613 IHTMLDocument2_AddRef(*p);
614 }else {
615 *p = NULL;
618 return S_OK;
621 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
623 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
625 TRACE("(%p)->(%p)\n", This, p);
627 if(This->event)
628 IHTMLEventObj_AddRef(This->event);
629 *p = This->event;
630 return S_OK;
633 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
635 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
636 FIXME("(%p)->(%p)\n", This, p);
637 return E_NOTIMPL;
640 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
641 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
643 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
644 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
645 return E_NOTIMPL;
648 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
649 BSTR features)
651 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
652 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
653 return E_NOTIMPL;
656 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
658 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
659 FIXME("(%p)->(%p)\n", This, p);
660 return E_NOTIMPL;
663 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
665 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
667 TRACE("(%p)->(%p)\n", This, p);
669 if(!This->doc->option_factory)
670 This->doc->option_factory = HTMLOptionElementFactory_Create(This->doc);
672 *p = HTMLOPTFACTORY(This->doc->option_factory);
673 IHTMLOptionElementFactory_AddRef(*p);
675 return S_OK;
678 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
680 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
681 FIXME("(%p)->()\n", This);
682 return E_NOTIMPL;
685 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
687 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
688 FIXME("(%p)->(%p)\n", This, p);
689 return E_NOTIMPL;
692 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
694 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
695 FIXME("(%p)->()\n", This);
696 return E_NOTIMPL;
699 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
701 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
702 FIXME("(%p)->(%d %d)\n", This, x, y);
703 return E_NOTIMPL;
706 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
708 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
709 FIXME("(%p)->(%p)\n", This, p);
710 return E_NOTIMPL;
713 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
714 LONG msec, VARIANT *language, LONG *timerID)
716 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
717 VARIANT expr;
719 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
721 V_VT(&expr) = VT_BSTR;
722 V_BSTR(&expr) = expression;
723 return IHTMLWindow3_setInterval(HTMLWINDOW3(This), &expr, msec, language, timerID);
726 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
728 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
730 TRACE("(%p)->(%d)\n", This, timerID);
732 return clear_task_timer(This->doc, TRUE, timerID);
735 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
737 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
738 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
739 return E_NOTIMPL;
742 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
744 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
745 FIXME("(%p)->(%p)\n", This, p);
746 return E_NOTIMPL;
749 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
750 VARIANT *pvarRet)
752 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
753 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
754 return E_NOTIMPL;
757 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
759 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
761 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
763 TRACE("(%p)->(%p)\n", This, String);
765 if(!String)
766 return E_INVALIDARG;
768 *String = SysAllocString(objectW);
769 return *String ? S_OK : E_OUTOFMEMORY;
772 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
774 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
775 nsresult nsres;
777 TRACE("(%p)->(%d %d)\n", This, x, y);
779 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
780 if(NS_FAILED(nsres))
781 ERR("ScrollBy failed: %08x\n", nsres);
783 return S_OK;
786 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
788 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
789 nsresult nsres;
791 TRACE("(%p)->(%d %d)\n", This, x, y);
793 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
794 if(NS_FAILED(nsres))
795 ERR("ScrollTo failed: %08x\n", nsres);
797 return S_OK;
800 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
802 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
803 FIXME("(%p)->(%d %d)\n", This, x, y);
804 return E_NOTIMPL;
807 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
809 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
810 FIXME("(%p)->(%d %d)\n", This, x, y);
811 return E_NOTIMPL;
814 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
816 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
817 FIXME("(%p)->(%d %d)\n", This, x, y);
818 return E_NOTIMPL;
821 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
823 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
824 FIXME("(%p)->(%d %d)\n", This, x, y);
825 return E_NOTIMPL;
828 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
830 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
832 TRACE("(%p)->(%p)\n", This, p);
834 *p = NULL;
836 if(!This->doc->hostui)
837 return S_OK;
839 return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
842 #undef HTMLWINDOW2_THIS
844 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
845 HTMLWindow2_QueryInterface,
846 HTMLWindow2_AddRef,
847 HTMLWindow2_Release,
848 HTMLWindow2_GetTypeInfoCount,
849 HTMLWindow2_GetTypeInfo,
850 HTMLWindow2_GetIDsOfNames,
851 HTMLWindow2_Invoke,
852 HTMLWindow2_item,
853 HTMLWindow2_get_length,
854 HTMLWindow2_get_frames,
855 HTMLWindow2_put_defaultStatus,
856 HTMLWindow2_get_defaultStatus,
857 HTMLWindow2_put_status,
858 HTMLWindow2_get_status,
859 HTMLWindow2_setTimeout,
860 HTMLWindow2_clearTimeout,
861 HTMLWindow2_alert,
862 HTMLWindow2_confirm,
863 HTMLWindow2_prompt,
864 HTMLWindow2_get_Image,
865 HTMLWindow2_get_location,
866 HTMLWindow2_get_history,
867 HTMLWindow2_close,
868 HTMLWindow2_put_opener,
869 HTMLWindow2_get_opener,
870 HTMLWindow2_get_navigator,
871 HTMLWindow2_put_name,
872 HTMLWindow2_get_name,
873 HTMLWindow2_get_parent,
874 HTMLWindow2_open,
875 HTMLWindow2_get_self,
876 HTMLWindow2_get_top,
877 HTMLWindow2_get_window,
878 HTMLWindow2_navigate,
879 HTMLWindow2_put_onfocus,
880 HTMLWindow2_get_onfocus,
881 HTMLWindow2_put_onblur,
882 HTMLWindow2_get_onblur,
883 HTMLWindow2_put_onload,
884 HTMLWindow2_get_onload,
885 HTMLWindow2_put_onbeforeunload,
886 HTMLWindow2_get_onbeforeunload,
887 HTMLWindow2_put_onunload,
888 HTMLWindow2_get_onunload,
889 HTMLWindow2_put_onhelp,
890 HTMLWindow2_get_onhelp,
891 HTMLWindow2_put_onerror,
892 HTMLWindow2_get_onerror,
893 HTMLWindow2_put_onresize,
894 HTMLWindow2_get_onresize,
895 HTMLWindow2_put_onscroll,
896 HTMLWindow2_get_onscroll,
897 HTMLWindow2_get_document,
898 HTMLWindow2_get_event,
899 HTMLWindow2_get__newEnum,
900 HTMLWindow2_showModalDialog,
901 HTMLWindow2_showHelp,
902 HTMLWindow2_get_screen,
903 HTMLWindow2_get_Option,
904 HTMLWindow2_focus,
905 HTMLWindow2_get_closed,
906 HTMLWindow2_blur,
907 HTMLWindow2_scroll,
908 HTMLWindow2_get_clientInformation,
909 HTMLWindow2_setInterval,
910 HTMLWindow2_clearInterval,
911 HTMLWindow2_put_offscreenBuffering,
912 HTMLWindow2_get_offscreenBuffering,
913 HTMLWindow2_execScript,
914 HTMLWindow2_toString,
915 HTMLWindow2_scrollBy,
916 HTMLWindow2_scrollTo,
917 HTMLWindow2_moveTo,
918 HTMLWindow2_moveBy,
919 HTMLWindow2_resizeTo,
920 HTMLWindow2_resizeBy,
921 HTMLWindow2_get_external
924 #define HTMLWINDOW3_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow3, iface)
926 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
928 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
930 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
933 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
935 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
937 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
940 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
942 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
944 return IHTMLWindow2_Release(HTMLWINDOW2(This));
947 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
949 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
951 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
954 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
955 LCID lcid, ITypeInfo **ppTInfo)
957 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
959 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
962 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
963 LPOLESTR *rgszNames, UINT cNames,
964 LCID lcid, DISPID *rgDispId)
966 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
968 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
971 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
972 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
973 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
975 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
977 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
978 pVarResult, pExcepInfo, puArgErr);
981 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
983 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
984 FIXME("(%p)->(%p)\n", This, p);
985 return E_NOTIMPL;
988 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
990 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
991 FIXME("(%p)->(%p)\n", This, p);
992 return E_NOTIMPL;
995 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
997 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
998 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
999 return E_NOTIMPL;
1002 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1004 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1005 FIXME("(%p)->()\n", This);
1006 return E_NOTIMPL;
1009 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1010 BOOL interval, LONG *timer_id)
1012 IDispatch *disp = NULL;
1014 switch(V_VT(expr)) {
1015 case VT_DISPATCH:
1016 disp = V_DISPATCH(expr);
1017 IDispatch_AddRef(disp);
1018 break;
1020 case VT_BSTR:
1021 disp = script_parse_event(This->doc, V_BSTR(expr));
1022 break;
1024 default:
1025 FIXME("unimplemented vt=%d\n", V_VT(expr));
1026 return E_NOTIMPL;
1029 if(!disp)
1030 return E_FAIL;
1032 *timer_id = set_task_timer(This->doc, msec, interval, disp);
1033 IDispatch_Release(disp);
1035 return S_OK;
1038 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1039 VARIANT *language, LONG *timerID)
1041 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1043 TRACE("(%p)->(%p(%d) %d %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
1045 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1048 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1049 VARIANT *language, LONG *timerID)
1051 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1053 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1055 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1058 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1060 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1061 FIXME("(%p)\n", This);
1062 return E_NOTIMPL;
1065 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1067 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1068 FIXME("(%p)->()\n", This);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1074 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1075 FIXME("(%p)->(%p)\n", This, p);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1081 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1082 FIXME("(%p)->()\n", This);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1088 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1089 FIXME("(%p)->(%p)\n", This, p);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1095 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1096 FIXME("(%p)->(%p)\n", This, p);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1101 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1103 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1104 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1105 return E_NOTIMPL;
1108 #undef HTMLWINDOW3_THIS
1110 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1111 HTMLWindow3_QueryInterface,
1112 HTMLWindow3_AddRef,
1113 HTMLWindow3_Release,
1114 HTMLWindow3_GetTypeInfoCount,
1115 HTMLWindow3_GetTypeInfo,
1116 HTMLWindow3_GetIDsOfNames,
1117 HTMLWindow3_Invoke,
1118 HTMLWindow3_get_screenLeft,
1119 HTMLWindow3_get_screenTop,
1120 HTMLWindow3_attachEvent,
1121 HTMLWindow3_detachEvent,
1122 HTMLWindow3_setTimeout,
1123 HTMLWindow3_setInterval,
1124 HTMLWindow3_print,
1125 HTMLWindow3_put_onbeforeprint,
1126 HTMLWindow3_get_onbeforeprint,
1127 HTMLWindow3_put_onafterprint,
1128 HTMLWindow3_get_onafterprint,
1129 HTMLWindow3_get_clipboardData,
1130 HTMLWindow3_showModelessDialog
1133 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
1135 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1137 HTMLWindow *This = DISPEX_THIS(iface);
1139 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
1142 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
1144 HTMLWindow *This = DISPEX_THIS(iface);
1146 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
1149 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
1151 HTMLWindow *This = DISPEX_THIS(iface);
1153 return IHTMLWindow2_Release(HTMLWINDOW2(This));
1156 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1158 HTMLWindow *This = DISPEX_THIS(iface);
1160 TRACE("(%p)->(%p)\n", This, pctinfo);
1162 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1165 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1166 LCID lcid, ITypeInfo **ppTInfo)
1168 HTMLWindow *This = DISPEX_THIS(iface);
1170 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1172 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1175 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1176 LPOLESTR *rgszNames, UINT cNames,
1177 LCID lcid, DISPID *rgDispId)
1179 HTMLWindow *This = DISPEX_THIS(iface);
1181 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1182 lcid, rgDispId);
1184 /* FIXME: Use script dispatch */
1186 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1189 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1190 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1191 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1193 HTMLWindow *This = DISPEX_THIS(iface);
1195 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1196 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1198 /* FIXME: Use script dispatch */
1200 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1201 pVarResult, pExcepInfo, puArgErr);
1204 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1206 HTMLWindow *This = DISPEX_THIS(iface);
1208 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
1210 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1213 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1214 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1216 HTMLWindow *This = DISPEX_THIS(iface);
1218 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1220 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1223 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1225 HTMLWindow *This = DISPEX_THIS(iface);
1227 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
1229 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1232 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1234 HTMLWindow *This = DISPEX_THIS(iface);
1236 TRACE("(%p)->(%x)\n", This, id);
1238 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1241 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1243 HTMLWindow *This = DISPEX_THIS(iface);
1245 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
1247 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1250 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1252 HTMLWindow *This = DISPEX_THIS(iface);
1254 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
1256 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1259 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1261 HTMLWindow *This = DISPEX_THIS(iface);
1263 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
1265 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1268 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1270 HTMLWindow *This = DISPEX_THIS(iface);
1272 TRACE("(%p)->(%p)\n", This, ppunk);
1274 *ppunk = NULL;
1275 return S_OK;
1278 #undef DISPEX_THIS
1280 static const IDispatchExVtbl WindowDispExVtbl = {
1281 WindowDispEx_QueryInterface,
1282 WindowDispEx_AddRef,
1283 WindowDispEx_Release,
1284 WindowDispEx_GetTypeInfoCount,
1285 WindowDispEx_GetTypeInfo,
1286 WindowDispEx_GetIDsOfNames,
1287 WindowDispEx_Invoke,
1288 WindowDispEx_GetDispID,
1289 WindowDispEx_InvokeEx,
1290 WindowDispEx_DeleteMemberByName,
1291 WindowDispEx_DeleteMemberByDispID,
1292 WindowDispEx_GetMemberProperties,
1293 WindowDispEx_GetMemberName,
1294 WindowDispEx_GetNextDispID,
1295 WindowDispEx_GetNameSpaceParent
1298 static const tid_t HTMLWindow_iface_tids[] = {
1299 IHTMLWindow2_tid,
1300 IHTMLWindow3_tid,
1303 static dispex_static_data_t HTMLWindow_dispex = {
1304 NULL,
1305 DispHTMLWindow2_tid,
1306 NULL,
1307 HTMLWindow_iface_tids
1310 HRESULT HTMLWindow_Create(HTMLDocument *doc, nsIDOMWindow *nswindow, HTMLWindow **ret)
1312 HTMLWindow *window;
1314 window = heap_alloc_zero(sizeof(HTMLWindow));
1315 if(!window)
1316 return E_OUTOFMEMORY;
1318 window->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
1319 window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
1320 window->lpIDispatchExVtbl = &WindowDispExVtbl;
1321 window->ref = 1;
1322 window->doc = doc;
1324 init_dispex(&window->dispex, (IUnknown*)HTMLWINDOW2(window), &HTMLWindow_dispex);
1326 if(nswindow) {
1327 nsIDOMWindow_AddRef(nswindow);
1328 window->nswindow = nswindow;
1331 list_add_head(&window_list, &window->entry);
1333 *ret = window;
1334 return S_OK;
1337 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
1339 HTMLWindow *iter;
1341 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
1342 if(iter->nswindow == nswindow)
1343 return iter;
1346 return NULL;