msctf: Correct handling if NULL for pdimFocus in ITfThreadMgr::SetFocus.
[wine/multimedia.git] / dlls / mshtml / htmlwindow.c
blobd50eca17758068490419937c6d6c503f22e7e984
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 "resource.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 static struct list window_list = LIST_INIT(window_list);
38 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
40 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
42 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
44 *ppv = NULL;
46 if(IsEqualGUID(&IID_IUnknown, riid)) {
47 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
48 *ppv = HTMLWINDOW2(This);
49 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
50 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
51 *ppv = HTMLWINDOW2(This);
52 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
53 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
54 *ppv = DISPATCHEX(This);
55 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
56 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
57 *ppv = HTMLWINDOW2(This);
58 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
59 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
60 *ppv = HTMLWINDOW2(This);
61 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
62 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
63 *ppv = HTMLWINDOW3(This);
64 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
65 return *ppv ? S_OK : E_NOINTERFACE;
68 if(*ppv) {
69 IUnknown_AddRef((IUnknown*)*ppv);
70 return S_OK;
73 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
74 return E_NOINTERFACE;
77 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
79 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
80 LONG ref = InterlockedIncrement(&This->ref);
82 TRACE("(%p) ref=%d\n", This, ref);
84 return ref;
87 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
89 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
90 LONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p) ref=%d\n", This, ref);
94 if(!ref) {
95 list_remove(&This->entry);
96 release_dispex(&This->dispex);
97 heap_free(This);
100 return ref;
103 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
105 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
107 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
110 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
111 LCID lcid, ITypeInfo **ppTInfo)
113 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
115 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
118 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
119 LPOLESTR *rgszNames, UINT cNames,
120 LCID lcid, DISPID *rgDispId)
122 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
124 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
127 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
128 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
129 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
131 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
133 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
134 pVarResult, pExcepInfo, puArgErr);
137 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
139 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
140 FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
141 return E_NOTIMPL;
144 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
146 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
147 FIXME("(%p)->(%p)\n", This, p);
148 return E_NOTIMPL;
151 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
153 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
154 FIXME("(%p)->(%p)\n", This, p);
155 return E_NOTIMPL;
158 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
160 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
161 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
162 return E_NOTIMPL;
165 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
167 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
168 FIXME("(%p)->(%p)\n", This, p);
169 return E_NOTIMPL;
172 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
174 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
175 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
176 return E_NOTIMPL;
179 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
181 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
182 FIXME("(%p)->(%p)\n", This, p);
183 return E_NOTIMPL;
186 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
187 LONG msec, VARIANT *language, LONG *timerID)
189 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
190 VARIANT expr_var;
192 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
194 V_VT(&expr_var) = VT_BSTR;
195 V_BSTR(&expr_var) = expression;
197 return IHTMLWindow3_setTimeout(HTMLWINDOW3(This), &expr_var, msec, language, timerID);
200 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
202 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
204 TRACE("(%p)->(%d)\n", This, timerID);
206 return clear_task_timer(This->doc, FALSE, timerID);
209 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
211 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
212 WCHAR wszTitle[100];
214 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
216 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
217 sizeof(wszTitle)/sizeof(WCHAR))) {
218 WARN("Could not load message box title: %d\n", GetLastError());
219 return S_OK;
222 MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
223 return S_OK;
226 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
227 VARIANT_BOOL *confirmed)
229 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
230 WCHAR wszTitle[100];
232 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
234 if(!confirmed) return E_INVALIDARG;
236 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
237 sizeof(wszTitle)/sizeof(WCHAR))) {
238 WARN("Could not load message box title: %d\n", GetLastError());
239 *confirmed = VARIANT_TRUE;
240 return S_OK;
243 if(MessageBoxW(This->doc->hwnd, message, wszTitle,
244 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
245 *confirmed = VARIANT_TRUE;
246 else *confirmed = VARIANT_FALSE;
248 return S_OK;
251 typedef struct
253 BSTR message;
254 BSTR dststr;
255 VARIANT *textdata;
256 }prompt_arg;
258 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
259 WPARAM wparam, LPARAM lparam)
261 switch(msg)
263 case WM_INITDIALOG:
265 prompt_arg *arg = (prompt_arg*)lparam;
266 WCHAR wszTitle[100];
268 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
269 sizeof(wszTitle)/sizeof(WCHAR))) {
270 WARN("Could not load message box title: %d\n", GetLastError());
271 EndDialog(hwnd, wparam);
272 return FALSE;
275 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
276 SetWindowTextW(hwnd, wszTitle);
277 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
278 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
279 return FALSE;
281 case WM_COMMAND:
282 switch(wparam)
284 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
285 EndDialog(hwnd, wparam);
286 return TRUE;
287 case MAKEWPARAM(IDOK, BN_CLICKED):
289 prompt_arg *arg =
290 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
291 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
292 INT len = GetWindowTextLengthW(hwndPrompt);
294 if(!arg->textdata)
296 EndDialog(hwnd, wparam);
297 return TRUE;
300 V_VT(arg->textdata) = VT_BSTR;
301 if(!len && !arg->dststr)
302 V_BSTR(arg->textdata) = NULL;
303 else
305 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
306 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
308 EndDialog(hwnd, wparam);
309 return TRUE;
312 return FALSE;
313 case WM_CLOSE:
314 EndDialog(hwnd, IDCANCEL);
315 return TRUE;
316 default:
317 return FALSE;
321 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
322 BSTR dststr, VARIANT *textdata)
324 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
325 prompt_arg arg;
327 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
329 if(textdata) V_VT(textdata) = VT_NULL;
331 arg.message = message;
332 arg.dststr = dststr;
333 arg.textdata = textdata;
335 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
336 This->doc->hwnd, prompt_dlgproc, (LPARAM)&arg);
337 return S_OK;
340 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
342 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
343 FIXME("(%p)->(%p)\n", This, p);
344 return E_NOTIMPL;
347 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
349 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
351 TRACE("(%p)->(%p)\n", This, p);
353 if(!This->doc) {
354 FIXME("This->doc is NULL\n");
355 return E_FAIL;
358 return IHTMLDocument2_get_location(HTMLDOC(This->doc), p);
361 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
363 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
364 FIXME("(%p)->(%p)\n", This, p);
365 return E_NOTIMPL;
368 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
370 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
371 FIXME("(%p)->()\n", This);
372 return E_NOTIMPL;
375 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
377 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
378 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
379 return E_NOTIMPL;
382 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
384 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
385 FIXME("(%p)->(%p)\n", This, p);
386 return E_NOTIMPL;
389 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
391 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
393 TRACE("(%p)->(%p)\n", This, p);
395 *p = OmNavigator_Create();
396 return S_OK;
399 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
401 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
402 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
403 return E_NOTIMPL;
406 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
408 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
409 FIXME("(%p)->(%p)\n", This, p);
410 return E_NOTIMPL;
413 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
415 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
416 FIXME("(%p)->(%p)\n", This, p);
417 return E_NOTIMPL;
420 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
421 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
423 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
424 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
425 debugstr_w(features), replace, pomWindowResult);
426 return E_NOTIMPL;
429 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
431 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
433 TRACE("(%p)->(%p)\n", This, p);
435 /* FIXME: We should return kind of proxy window here. */
436 IHTMLWindow2_AddRef(HTMLWINDOW2(This));
437 *p = HTMLWINDOW2(This);
438 return S_OK;
441 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
443 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
444 FIXME("(%p)->(%p)\n", This, p);
445 return E_NOTIMPL;
448 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
450 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
452 TRACE("(%p)->(%p)\n", This, p);
454 /* FIXME: We should return kind of proxy window here. */
455 IHTMLWindow2_AddRef(HTMLWINDOW2(This));
456 *p = HTMLWINDOW2(This);
457 return S_OK;
460 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
462 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
463 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
464 return E_NOTIMPL;
467 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
469 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
470 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
471 return E_NOTIMPL;
474 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
476 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
477 FIXME("(%p)->(%p)\n", This, p);
478 return E_NOTIMPL;
481 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
483 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
484 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
485 return E_NOTIMPL;
488 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
490 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
491 FIXME("(%p)->(%p)\n", This, p);
492 return E_NOTIMPL;
495 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
497 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
498 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
499 return E_NOTIMPL;
502 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
504 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
505 FIXME("(%p)->(%p)\n", This, p);
506 return E_NOTIMPL;
509 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
511 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
512 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
513 return E_NOTIMPL;
516 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
518 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
519 FIXME("(%p)->(%p)\n", This, p);
520 return E_NOTIMPL;
523 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
525 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
526 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
527 return E_NOTIMPL;
530 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
532 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
533 FIXME("(%p)->(%p)\n", This, p);
534 return E_NOTIMPL;
537 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
539 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
540 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
541 return E_NOTIMPL;
544 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
546 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
547 FIXME("(%p)->(%p)\n", This, p);
548 return E_NOTIMPL;
551 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
553 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
554 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
555 return E_NOTIMPL;
558 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
560 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
561 FIXME("(%p)->(%p)\n", This, p);
562 return E_NOTIMPL;
565 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
567 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
568 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
569 return E_NOTIMPL;
572 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
574 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
575 FIXME("(%p)->(%p)\n", This, p);
576 return E_NOTIMPL;
579 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
581 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
582 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
583 return E_NOTIMPL;
586 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
588 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
589 FIXME("(%p)->(%p)\n", This, p);
590 return E_NOTIMPL;
593 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
595 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
597 TRACE("(%p)->(%p)\n", This, p);
599 if(This->doc) {
600 /* FIXME: We should return a wrapper object here */
601 *p = HTMLDOC(This->doc);
602 IHTMLDocument2_AddRef(*p);
603 }else {
604 *p = NULL;
607 return S_OK;
610 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
612 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
614 TRACE("(%p)->(%p)\n", This, p);
616 if(This->event)
617 IHTMLEventObj_AddRef(This->event);
618 *p = This->event;
619 return S_OK;
622 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
624 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
625 FIXME("(%p)->(%p)\n", This, p);
626 return E_NOTIMPL;
629 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
630 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
632 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
633 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
634 return E_NOTIMPL;
637 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
638 BSTR features)
640 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
641 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
642 return E_NOTIMPL;
645 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
647 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
648 FIXME("(%p)->(%p)\n", This, p);
649 return E_NOTIMPL;
652 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
654 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
656 TRACE("(%p)->(%p)\n", This, p);
658 if(!This->doc->option_factory)
659 This->doc->option_factory = HTMLOptionElementFactory_Create(This->doc);
661 *p = HTMLOPTFACTORY(This->doc->option_factory);
662 IHTMLOptionElementFactory_AddRef(*p);
664 return S_OK;
667 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
669 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
670 FIXME("(%p)->()\n", This);
671 return E_NOTIMPL;
674 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
676 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
677 FIXME("(%p)->(%p)\n", This, p);
678 return E_NOTIMPL;
681 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
683 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
684 FIXME("(%p)->()\n", This);
685 return E_NOTIMPL;
688 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
690 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
691 FIXME("(%p)->(%d %d)\n", This, x, y);
692 return E_NOTIMPL;
695 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
697 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
698 FIXME("(%p)->(%p)\n", This, p);
699 return E_NOTIMPL;
702 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
703 LONG msec, VARIANT *language, LONG *timerID)
705 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
706 VARIANT expr;
708 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
710 V_VT(&expr) = VT_BSTR;
711 V_BSTR(&expr) = expression;
712 return IHTMLWindow3_setInterval(HTMLWINDOW3(This), &expr, msec, language, timerID);
715 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
717 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
719 TRACE("(%p)->(%d)\n", This, timerID);
721 return clear_task_timer(This->doc, TRUE, timerID);
724 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
726 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
727 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
728 return E_NOTIMPL;
731 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
733 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
734 FIXME("(%p)->(%p)\n", This, p);
735 return E_NOTIMPL;
738 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
739 VARIANT *pvarRet)
741 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
742 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
743 return E_NOTIMPL;
746 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
748 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
750 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
752 TRACE("(%p)->(%p)\n", This, String);
754 if(!String)
755 return E_INVALIDARG;
757 *String = SysAllocString(objectW);
758 return *String ? S_OK : E_OUTOFMEMORY;
761 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
763 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
764 nsresult nsres;
766 TRACE("(%p)->(%d %d)\n", This, x, y);
768 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
769 if(NS_FAILED(nsres))
770 ERR("ScrollBy failed: %08x\n", nsres);
772 return S_OK;
775 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
777 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
778 nsresult nsres;
780 TRACE("(%p)->(%d %d)\n", This, x, y);
782 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
783 if(NS_FAILED(nsres))
784 ERR("ScrollTo failed: %08x\n", nsres);
786 return S_OK;
789 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
791 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
792 FIXME("(%p)->(%d %d)\n", This, x, y);
793 return E_NOTIMPL;
796 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
798 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
799 FIXME("(%p)->(%d %d)\n", This, x, y);
800 return E_NOTIMPL;
803 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
805 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
806 FIXME("(%p)->(%d %d)\n", This, x, y);
807 return E_NOTIMPL;
810 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
812 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
813 FIXME("(%p)->(%d %d)\n", This, x, y);
814 return E_NOTIMPL;
817 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
819 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
821 TRACE("(%p)->(%p)\n", This, p);
823 *p = NULL;
825 if(!This->doc->hostui)
826 return S_OK;
828 return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
831 #undef HTMLWINDOW2_THIS
833 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
834 HTMLWindow2_QueryInterface,
835 HTMLWindow2_AddRef,
836 HTMLWindow2_Release,
837 HTMLWindow2_GetTypeInfoCount,
838 HTMLWindow2_GetTypeInfo,
839 HTMLWindow2_GetIDsOfNames,
840 HTMLWindow2_Invoke,
841 HTMLWindow2_item,
842 HTMLWindow2_get_length,
843 HTMLWindow2_get_frames,
844 HTMLWindow2_put_defaultStatus,
845 HTMLWindow2_get_defaultStatus,
846 HTMLWindow2_put_status,
847 HTMLWindow2_get_status,
848 HTMLWindow2_setTimeout,
849 HTMLWindow2_clearTimeout,
850 HTMLWindow2_alert,
851 HTMLWindow2_confirm,
852 HTMLWindow2_prompt,
853 HTMLWindow2_get_Image,
854 HTMLWindow2_get_location,
855 HTMLWindow2_get_history,
856 HTMLWindow2_close,
857 HTMLWindow2_put_opener,
858 HTMLWindow2_get_opener,
859 HTMLWindow2_get_navigator,
860 HTMLWindow2_put_name,
861 HTMLWindow2_get_name,
862 HTMLWindow2_get_parent,
863 HTMLWindow2_open,
864 HTMLWindow2_get_self,
865 HTMLWindow2_get_top,
866 HTMLWindow2_get_window,
867 HTMLWindow2_navigate,
868 HTMLWindow2_put_onfocus,
869 HTMLWindow2_get_onfocus,
870 HTMLWindow2_put_onblur,
871 HTMLWindow2_get_onblur,
872 HTMLWindow2_put_onload,
873 HTMLWindow2_get_onload,
874 HTMLWindow2_put_onbeforeunload,
875 HTMLWindow2_get_onbeforeunload,
876 HTMLWindow2_put_onunload,
877 HTMLWindow2_get_onunload,
878 HTMLWindow2_put_onhelp,
879 HTMLWindow2_get_onhelp,
880 HTMLWindow2_put_onerror,
881 HTMLWindow2_get_onerror,
882 HTMLWindow2_put_onresize,
883 HTMLWindow2_get_onresize,
884 HTMLWindow2_put_onscroll,
885 HTMLWindow2_get_onscroll,
886 HTMLWindow2_get_document,
887 HTMLWindow2_get_event,
888 HTMLWindow2_get__newEnum,
889 HTMLWindow2_showModalDialog,
890 HTMLWindow2_showHelp,
891 HTMLWindow2_get_screen,
892 HTMLWindow2_get_Option,
893 HTMLWindow2_focus,
894 HTMLWindow2_get_closed,
895 HTMLWindow2_blur,
896 HTMLWindow2_scroll,
897 HTMLWindow2_get_clientInformation,
898 HTMLWindow2_setInterval,
899 HTMLWindow2_clearInterval,
900 HTMLWindow2_put_offscreenBuffering,
901 HTMLWindow2_get_offscreenBuffering,
902 HTMLWindow2_execScript,
903 HTMLWindow2_toString,
904 HTMLWindow2_scrollBy,
905 HTMLWindow2_scrollTo,
906 HTMLWindow2_moveTo,
907 HTMLWindow2_moveBy,
908 HTMLWindow2_resizeTo,
909 HTMLWindow2_resizeBy,
910 HTMLWindow2_get_external
913 #define HTMLWINDOW3_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow3, iface)
915 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
917 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
919 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
922 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
924 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
926 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
929 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
931 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
933 return IHTMLWindow2_Release(HTMLWINDOW2(This));
936 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
938 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
940 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
943 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
944 LCID lcid, ITypeInfo **ppTInfo)
946 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
948 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
951 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
952 LPOLESTR *rgszNames, UINT cNames,
953 LCID lcid, DISPID *rgDispId)
955 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
957 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
960 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
961 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
962 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
964 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
966 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
967 pVarResult, pExcepInfo, puArgErr);
970 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
972 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
973 FIXME("(%p)->(%p)\n", This, p);
974 return E_NOTIMPL;
977 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
979 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
980 FIXME("(%p)->(%p)\n", This, p);
981 return E_NOTIMPL;
984 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
986 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
987 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
988 return E_NOTIMPL;
991 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
993 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
994 FIXME("(%p)->()\n", This);
995 return E_NOTIMPL;
998 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
999 BOOL interval, LONG *timer_id)
1001 IDispatch *disp = NULL;
1003 switch(V_VT(expr)) {
1004 case VT_DISPATCH:
1005 disp = V_DISPATCH(expr);
1006 IDispatch_AddRef(disp);
1007 break;
1009 case VT_BSTR:
1010 disp = script_parse_event(This->doc, V_BSTR(expr));
1011 break;
1013 default:
1014 FIXME("unimplemented vt=%d\n", V_VT(expr));
1015 return E_NOTIMPL;
1018 if(!disp)
1019 return E_FAIL;
1021 *timer_id = set_task_timer(This->doc, msec, interval, disp);
1022 IDispatch_Release(disp);
1024 return S_OK;
1027 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1028 VARIANT *language, LONG *timerID)
1030 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1032 TRACE("(%p)->(%p(%d) %d %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
1034 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1037 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1038 VARIANT *language, LONG *timerID)
1040 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1042 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1044 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1047 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1049 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1050 FIXME("(%p)\n", This);
1051 return E_NOTIMPL;
1054 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1056 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1057 FIXME("(%p)->()\n", This);
1058 return E_NOTIMPL;
1061 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1063 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1064 FIXME("(%p)->(%p)\n", This, p);
1065 return E_NOTIMPL;
1068 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1070 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1071 FIXME("(%p)->()\n", This);
1072 return E_NOTIMPL;
1075 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1077 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1078 FIXME("(%p)->(%p)\n", This, p);
1079 return E_NOTIMPL;
1082 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1084 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1085 FIXME("(%p)->(%p)\n", This, p);
1086 return E_NOTIMPL;
1089 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1090 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1092 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
1093 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1094 return E_NOTIMPL;
1097 #undef HTMLWINDOW3_THIS
1099 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1100 HTMLWindow3_QueryInterface,
1101 HTMLWindow3_AddRef,
1102 HTMLWindow3_Release,
1103 HTMLWindow3_GetTypeInfoCount,
1104 HTMLWindow3_GetTypeInfo,
1105 HTMLWindow3_GetIDsOfNames,
1106 HTMLWindow3_Invoke,
1107 HTMLWindow3_get_screenLeft,
1108 HTMLWindow3_get_screenTop,
1109 HTMLWindow3_attachEvent,
1110 HTMLWindow3_detachEvent,
1111 HTMLWindow3_setTimeout,
1112 HTMLWindow3_setInterval,
1113 HTMLWindow3_print,
1114 HTMLWindow3_put_onbeforeprint,
1115 HTMLWindow3_get_onbeforeprint,
1116 HTMLWindow3_put_onafterprint,
1117 HTMLWindow3_get_onafterprint,
1118 HTMLWindow3_get_clipboardData,
1119 HTMLWindow3_showModelessDialog
1122 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
1124 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1126 HTMLWindow *This = DISPEX_THIS(iface);
1128 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
1131 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
1133 HTMLWindow *This = DISPEX_THIS(iface);
1135 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
1138 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
1140 HTMLWindow *This = DISPEX_THIS(iface);
1142 return IHTMLWindow2_Release(HTMLWINDOW2(This));
1145 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1147 HTMLWindow *This = DISPEX_THIS(iface);
1149 TRACE("(%p)->(%p)\n", This, pctinfo);
1151 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1154 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1155 LCID lcid, ITypeInfo **ppTInfo)
1157 HTMLWindow *This = DISPEX_THIS(iface);
1159 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1161 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1164 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1165 LPOLESTR *rgszNames, UINT cNames,
1166 LCID lcid, DISPID *rgDispId)
1168 HTMLWindow *This = DISPEX_THIS(iface);
1170 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1171 lcid, rgDispId);
1173 /* FIXME: Use script dispatch */
1175 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1178 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1179 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1180 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1182 HTMLWindow *This = DISPEX_THIS(iface);
1184 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1185 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1187 /* FIXME: Use script dispatch */
1189 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1190 pVarResult, pExcepInfo, puArgErr);
1193 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1195 HTMLWindow *This = DISPEX_THIS(iface);
1197 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
1199 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1202 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1203 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1205 HTMLWindow *This = DISPEX_THIS(iface);
1207 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1209 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1212 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1214 HTMLWindow *This = DISPEX_THIS(iface);
1216 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
1218 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1221 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1223 HTMLWindow *This = DISPEX_THIS(iface);
1225 TRACE("(%p)->(%x)\n", This, id);
1227 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1230 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1232 HTMLWindow *This = DISPEX_THIS(iface);
1234 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
1236 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1239 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1241 HTMLWindow *This = DISPEX_THIS(iface);
1243 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
1245 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1248 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1250 HTMLWindow *This = DISPEX_THIS(iface);
1252 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
1254 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1257 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1259 HTMLWindow *This = DISPEX_THIS(iface);
1261 TRACE("(%p)->(%p)\n", This, ppunk);
1263 *ppunk = NULL;
1264 return S_OK;
1267 #undef DISPEX_THIS
1269 static const IDispatchExVtbl WindowDispExVtbl = {
1270 WindowDispEx_QueryInterface,
1271 WindowDispEx_AddRef,
1272 WindowDispEx_Release,
1273 WindowDispEx_GetTypeInfoCount,
1274 WindowDispEx_GetTypeInfo,
1275 WindowDispEx_GetIDsOfNames,
1276 WindowDispEx_Invoke,
1277 WindowDispEx_GetDispID,
1278 WindowDispEx_InvokeEx,
1279 WindowDispEx_DeleteMemberByName,
1280 WindowDispEx_DeleteMemberByDispID,
1281 WindowDispEx_GetMemberProperties,
1282 WindowDispEx_GetMemberName,
1283 WindowDispEx_GetNextDispID,
1284 WindowDispEx_GetNameSpaceParent
1287 static const tid_t HTMLWindow_iface_tids[] = {
1288 IHTMLWindow2_tid,
1289 IHTMLWindow3_tid,
1292 static dispex_static_data_t HTMLWindow_dispex = {
1293 NULL,
1294 DispHTMLWindow2_tid,
1295 NULL,
1296 HTMLWindow_iface_tids
1299 HRESULT HTMLWindow_Create(HTMLDocument *doc, nsIDOMWindow *nswindow, HTMLWindow **ret)
1301 HTMLWindow *window;
1303 window = heap_alloc_zero(sizeof(HTMLWindow));
1304 if(!window)
1305 return E_OUTOFMEMORY;
1307 window->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
1308 window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
1309 window->lpIDispatchExVtbl = &WindowDispExVtbl;
1310 window->ref = 1;
1311 window->doc = doc;
1313 init_dispex(&window->dispex, (IUnknown*)HTMLWINDOW2(window), &HTMLWindow_dispex);
1315 if(nswindow) {
1316 nsIDOMWindow_AddRef(nswindow);
1317 window->nswindow = nswindow;
1320 list_add_head(&window_list, &window->entry);
1322 *ret = window;
1323 return S_OK;
1326 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
1328 HTMLWindow *iter;
1330 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
1331 if(iter->nswindow == nswindow)
1332 return iter;
1335 return NULL;