2 * Copyright 2014 Piotr 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
21 #include "oleacc_private.h"
24 #include "wine/debug.h"
25 #include "wine/heap.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(oleacc
);
30 IAccessible IAccessible_iface
;
31 IOleWindow IOleWindow_iface
;
32 IEnumVARIANT IEnumVARIANT_iface
;
39 static inline Window
* impl_from_Window(IAccessible
*iface
)
41 return CONTAINING_RECORD(iface
, Window
, IAccessible_iface
);
44 static HRESULT WINAPI
Window_QueryInterface(IAccessible
*iface
, REFIID riid
, void **ppv
)
46 Window
*This
= impl_from_Window(iface
);
48 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
50 if(IsEqualIID(riid
, &IID_IAccessible
) ||
51 IsEqualIID(riid
, &IID_IDispatch
) ||
52 IsEqualIID(riid
, &IID_IUnknown
)) {
54 }else if(IsEqualIID(riid
, &IID_IOleWindow
)) {
55 *ppv
= &This
->IOleWindow_iface
;
56 }else if(IsEqualIID(riid
, &IID_IEnumVARIANT
)) {
57 *ppv
= &This
->IEnumVARIANT_iface
;
59 WARN("no interface: %s\n", debugstr_guid(riid
));
64 IAccessible_AddRef(iface
);
68 static ULONG WINAPI
Window_AddRef(IAccessible
*iface
)
70 Window
*This
= impl_from_Window(iface
);
71 ULONG ref
= InterlockedIncrement(&This
->ref
);
73 TRACE("(%p) ref = %lu\n", This
, ref
);
77 static ULONG WINAPI
Window_Release(IAccessible
*iface
)
79 Window
*This
= impl_from_Window(iface
);
80 ULONG ref
= InterlockedDecrement(&This
->ref
);
82 TRACE("(%p) ref = %lu\n", This
, ref
);
89 static HRESULT WINAPI
Window_GetTypeInfoCount(IAccessible
*iface
, UINT
*pctinfo
)
91 Window
*This
= impl_from_Window(iface
);
92 FIXME("(%p)->(%p)\n", This
, pctinfo
);
96 static HRESULT WINAPI
Window_GetTypeInfo(IAccessible
*iface
,
97 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
99 Window
*This
= impl_from_Window(iface
);
100 FIXME("(%p)->(%u %lx %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
104 static HRESULT WINAPI
Window_GetIDsOfNames(IAccessible
*iface
, REFIID riid
,
105 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
107 Window
*This
= impl_from_Window(iface
);
108 FIXME("(%p)->(%s %p %u %lx %p)\n", This
, debugstr_guid(riid
),
109 rgszNames
, cNames
, lcid
, rgDispId
);
113 static HRESULT WINAPI
Window_Invoke(IAccessible
*iface
, DISPID dispIdMember
,
114 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
115 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
117 Window
*This
= impl_from_Window(iface
);
118 FIXME("(%p)->(%lx %s %lx %x %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
119 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
123 static HRESULT WINAPI
Window_get_accParent(IAccessible
*iface
, IDispatch
**ppdispParent
)
125 Window
*This
= impl_from_Window(iface
);
126 FIXME("(%p)->(%p)\n", This
, ppdispParent
);
130 static HRESULT WINAPI
Window_get_accChildCount(IAccessible
*iface
, LONG
*pcountChildren
)
132 Window
*This
= impl_from_Window(iface
);
133 FIXME("(%p)->(%p)\n", This
, pcountChildren
);
137 static HRESULT WINAPI
Window_get_accChild(IAccessible
*iface
,
138 VARIANT varChildID
, IDispatch
**ppdispChild
)
140 Window
*This
= impl_from_Window(iface
);
141 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varChildID
), ppdispChild
);
145 static HRESULT WINAPI
Window_get_accName(IAccessible
*iface
, VARIANT varID
, BSTR
*pszName
)
147 Window
*This
= impl_from_Window(iface
);
148 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszName
);
152 static HRESULT WINAPI
Window_get_accValue(IAccessible
*iface
, VARIANT varID
, BSTR
*pszValue
)
154 Window
*This
= impl_from_Window(iface
);
155 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszValue
);
159 static HRESULT WINAPI
Window_get_accDescription(IAccessible
*iface
,
160 VARIANT varID
, BSTR
*pszDescription
)
162 Window
*This
= impl_from_Window(iface
);
163 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszDescription
);
167 static HRESULT WINAPI
Window_get_accRole(IAccessible
*iface
, VARIANT varID
, VARIANT
*pvarRole
)
169 Window
*This
= impl_from_Window(iface
);
170 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pvarRole
);
174 static HRESULT WINAPI
Window_get_accState(IAccessible
*iface
, VARIANT varID
, VARIANT
*pvarState
)
176 Window
*This
= impl_from_Window(iface
);
177 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pvarState
);
181 static HRESULT WINAPI
Window_get_accHelp(IAccessible
*iface
, VARIANT varID
, BSTR
*pszHelp
)
183 Window
*This
= impl_from_Window(iface
);
184 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszHelp
);
188 static HRESULT WINAPI
Window_get_accHelpTopic(IAccessible
*iface
,
189 BSTR
*pszHelpFile
, VARIANT varID
, LONG
*pidTopic
)
191 Window
*This
= impl_from_Window(iface
);
192 FIXME("(%p)->(%p %s %p)\n", This
, pszHelpFile
, debugstr_variant(&varID
), pidTopic
);
196 static HRESULT WINAPI
Window_get_accKeyboardShortcut(IAccessible
*iface
,
197 VARIANT varID
, BSTR
*pszKeyboardShortcut
)
199 Window
*This
= impl_from_Window(iface
);
200 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszKeyboardShortcut
);
204 static HRESULT WINAPI
Window_get_accFocus(IAccessible
*iface
, VARIANT
*pvarID
)
206 Window
*This
= impl_from_Window(iface
);
207 FIXME("(%p)->(%p)\n", This
, pvarID
);
211 static HRESULT WINAPI
Window_get_accSelection(IAccessible
*iface
, VARIANT
*pvarID
)
213 Window
*This
= impl_from_Window(iface
);
214 FIXME("(%p)->(%p)\n", This
, pvarID
);
218 static HRESULT WINAPI
Window_get_accDefaultAction(IAccessible
*iface
,
219 VARIANT varID
, BSTR
*pszDefaultAction
)
221 Window
*This
= impl_from_Window(iface
);
222 FIXME("(%p)->(%s %p)\n", This
, debugstr_variant(&varID
), pszDefaultAction
);
226 static HRESULT WINAPI
Window_accSelect(IAccessible
*iface
, LONG flagsSelect
, VARIANT varID
)
228 Window
*This
= impl_from_Window(iface
);
229 FIXME("(%p)->(%lx %s)\n", This
, flagsSelect
, debugstr_variant(&varID
));
233 static HRESULT WINAPI
Window_accLocation(IAccessible
*iface
, LONG
*pxLeft
,
234 LONG
*pyTop
, LONG
*pcxWidth
, LONG
*pcyHeight
, VARIANT varID
)
236 Window
*This
= impl_from_Window(iface
);
237 FIXME("(%p)->(%p %p %p %p %s)\n", This
, pxLeft
, pyTop
,
238 pcxWidth
, pcyHeight
, debugstr_variant(&varID
));
242 static HRESULT WINAPI
Window_accNavigate(IAccessible
*iface
,
243 LONG navDir
, VARIANT varStart
, VARIANT
*pvarEnd
)
245 Window
*This
= impl_from_Window(iface
);
246 FIXME("(%p)->(%ld %s %p)\n", This
, navDir
, debugstr_variant(&varStart
), pvarEnd
);
250 static HRESULT WINAPI
Window_accHitTest(IAccessible
*iface
, LONG x
, LONG y
, VARIANT
*v
)
252 Window
*This
= impl_from_Window(iface
);
258 TRACE("(%p)->(%ld %ld %p)\n", This
, x
, y
, v
);
261 if (!GetClientRect(This
->hwnd
, &rect
))
263 if (!ClientToScreen(This
->hwnd
, (POINT
*)&rect
) ||
264 !ClientToScreen(This
->hwnd
, &((POINT
*)&rect
)[1]))
268 if (PtInRect(&rect
, pt
))
270 hr
= AccessibleObjectFromWindow(This
->hwnd
, OBJID_CLIENT
, &IID_IDispatch
, (void**)&disp
);
276 V_VT(v
) = VT_DISPATCH
;
277 V_DISPATCH(v
) = disp
;
281 FIXME("non-client area not handled yet\n");
285 static HRESULT WINAPI
Window_accDoDefaultAction(IAccessible
*iface
, VARIANT varID
)
287 Window
*This
= impl_from_Window(iface
);
288 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&varID
));
292 static HRESULT WINAPI
Window_put_accName(IAccessible
*iface
, VARIANT varID
, BSTR pszName
)
294 Window
*This
= impl_from_Window(iface
);
295 FIXME("(%p)->(%s %s)\n", This
, debugstr_variant(&varID
), debugstr_w(pszName
));
299 static HRESULT WINAPI
Window_put_accValue(IAccessible
*iface
, VARIANT varID
, BSTR pszValue
)
301 Window
*This
= impl_from_Window(iface
);
302 FIXME("(%p)->(%s %s)\n", This
, debugstr_variant(&varID
), debugstr_w(pszValue
));
306 static const IAccessibleVtbl WindowVtbl
= {
307 Window_QueryInterface
,
310 Window_GetTypeInfoCount
,
312 Window_GetIDsOfNames
,
314 Window_get_accParent
,
315 Window_get_accChildCount
,
319 Window_get_accDescription
,
323 Window_get_accHelpTopic
,
324 Window_get_accKeyboardShortcut
,
326 Window_get_accSelection
,
327 Window_get_accDefaultAction
,
332 Window_accDoDefaultAction
,
337 static inline Window
* impl_from_Window_OleWindow(IOleWindow
*iface
)
339 return CONTAINING_RECORD(iface
, Window
, IOleWindow_iface
);
342 static HRESULT WINAPI
Window_OleWindow_QueryInterface(IOleWindow
*iface
, REFIID riid
, void **ppv
)
344 Window
*This
= impl_from_Window_OleWindow(iface
);
345 return IAccessible_QueryInterface(&This
->IAccessible_iface
, riid
, ppv
);
348 static ULONG WINAPI
Window_OleWindow_AddRef(IOleWindow
*iface
)
350 Window
*This
= impl_from_Window_OleWindow(iface
);
351 return IAccessible_AddRef(&This
->IAccessible_iface
);
354 static ULONG WINAPI
Window_OleWindow_Release(IOleWindow
*iface
)
356 Window
*This
= impl_from_Window_OleWindow(iface
);
357 return IAccessible_Release(&This
->IAccessible_iface
);
360 static HRESULT WINAPI
Window_OleWindow_GetWindow(IOleWindow
*iface
, HWND
*hwnd
)
362 Window
*This
= impl_from_Window_OleWindow(iface
);
364 TRACE("(%p)->(%p)\n", This
, hwnd
);
370 static HRESULT WINAPI
Window_OleWindow_ContextSensitiveHelp(IOleWindow
*iface
, BOOL fEnterMode
)
372 Window
*This
= impl_from_Window_OleWindow(iface
);
373 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
377 static const IOleWindowVtbl WindowOleWindowVtbl
= {
378 Window_OleWindow_QueryInterface
,
379 Window_OleWindow_AddRef
,
380 Window_OleWindow_Release
,
381 Window_OleWindow_GetWindow
,
382 Window_OleWindow_ContextSensitiveHelp
385 static inline Window
* impl_from_Window_EnumVARIANT(IEnumVARIANT
*iface
)
387 return CONTAINING_RECORD(iface
, Window
, IEnumVARIANT_iface
);
390 static HRESULT WINAPI
Window_EnumVARIANT_QueryInterface(IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
392 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
393 return IAccessible_QueryInterface(&This
->IAccessible_iface
, riid
, ppv
);
396 static ULONG WINAPI
Window_EnumVARIANT_AddRef(IEnumVARIANT
*iface
)
398 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
399 return IAccessible_AddRef(&This
->IAccessible_iface
);
402 static ULONG WINAPI
Window_EnumVARIANT_Release(IEnumVARIANT
*iface
)
404 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
405 return IAccessible_Release(&This
->IAccessible_iface
);
408 static HRESULT WINAPI
Window_EnumVARIANT_Next(IEnumVARIANT
*iface
,
409 ULONG celt
, VARIANT
*rgVar
, ULONG
*pCeltFetched
)
411 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
412 FIXME("(%p)->(%lu %p %p)\n", This
, celt
, rgVar
, pCeltFetched
);
416 static HRESULT WINAPI
Window_EnumVARIANT_Skip(IEnumVARIANT
*iface
, ULONG celt
)
418 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
419 FIXME("(%p)->(%lu)\n", This
, celt
);
423 static HRESULT WINAPI
Window_EnumVARIANT_Reset(IEnumVARIANT
*iface
)
425 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
426 FIXME("(%p)\n", This
);
430 static HRESULT WINAPI
Window_EnumVARIANT_Clone(IEnumVARIANT
*iface
, IEnumVARIANT
**ppEnum
)
432 Window
*This
= impl_from_Window_EnumVARIANT(iface
);
433 FIXME("(%p)->(%p)\n", This
, ppEnum
);
437 static const IEnumVARIANTVtbl WindowEnumVARIANTVtbl
= {
438 Window_EnumVARIANT_QueryInterface
,
439 Window_EnumVARIANT_AddRef
,
440 Window_EnumVARIANT_Release
,
441 Window_EnumVARIANT_Next
,
442 Window_EnumVARIANT_Skip
,
443 Window_EnumVARIANT_Reset
,
444 Window_EnumVARIANT_Clone
447 static const struct win_class_data classes
[] = {
448 {WC_LISTBOXW
, 0x10000, TRUE
},
449 {L
"#32768", 0x10001, TRUE
}, /* menu */
453 HRESULT
create_window_object(HWND hwnd
, const IID
*iid
, void **obj
)
461 window
= heap_alloc_zero(sizeof(Window
));
463 return E_OUTOFMEMORY
;
465 find_class_data(hwnd
, classes
);
467 window
->IAccessible_iface
.lpVtbl
= &WindowVtbl
;
468 window
->IOleWindow_iface
.lpVtbl
= &WindowOleWindowVtbl
;
469 window
->IEnumVARIANT_iface
.lpVtbl
= &WindowEnumVARIANTVtbl
;
473 hres
= IAccessible_QueryInterface(&window
->IAccessible_iface
, iid
, obj
);
474 IAccessible_Release(&window
->IAccessible_iface
);