win32u: Move NtUserGetMessage implementation from user32.
[wine.git] / dlls / oleacc / window.c
blob470bfd5b3627098a01ca47590e5bd968c60f3225
1 /*
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
19 #define COBJMACROS
21 #include "oleacc_private.h"
22 #include "commctrl.h"
24 #include "wine/debug.h"
25 #include "wine/heap.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(oleacc);
29 typedef struct {
30 IAccessible IAccessible_iface;
31 IOleWindow IOleWindow_iface;
32 IEnumVARIANT IEnumVARIANT_iface;
34 LONG ref;
36 HWND hwnd;
37 } Window;
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)) {
53 *ppv = iface;
54 }else if(IsEqualIID(riid, &IID_IOleWindow)) {
55 *ppv = &This->IOleWindow_iface;
56 }else if(IsEqualIID(riid, &IID_IEnumVARIANT)) {
57 *ppv = &This->IEnumVARIANT_iface;
58 }else {
59 WARN("no interface: %s\n", debugstr_guid(riid));
60 *ppv = NULL;
61 return E_NOINTERFACE;
64 IAccessible_AddRef(iface);
65 return S_OK;
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);
74 return 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);
84 if(!ref)
85 heap_free(This);
86 return 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);
93 return E_NOTIMPL;
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);
101 return E_NOTIMPL;
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);
110 return E_NOTIMPL;
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);
120 return E_NOTIMPL;
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);
127 return E_NOTIMPL;
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);
134 return E_NOTIMPL;
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);
142 return E_NOTIMPL;
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);
149 return E_NOTIMPL;
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);
156 return E_NOTIMPL;
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);
164 return E_NOTIMPL;
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);
171 return E_NOTIMPL;
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);
178 return E_NOTIMPL;
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);
185 return E_NOTIMPL;
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);
193 return E_NOTIMPL;
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);
201 return E_NOTIMPL;
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);
208 return E_NOTIMPL;
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);
215 return E_NOTIMPL;
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);
223 return E_NOTIMPL;
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));
230 return E_NOTIMPL;
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));
239 return E_NOTIMPL;
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);
247 return E_NOTIMPL;
250 static HRESULT WINAPI Window_accHitTest(IAccessible *iface, LONG x, LONG y, VARIANT *v)
252 Window *This = impl_from_Window(iface);
253 IDispatch *disp;
254 POINT pt;
255 HRESULT hr;
256 RECT rect;
258 TRACE("(%p)->(%ld %ld %p)\n", This, x, y, v);
260 V_VT(v) = VT_EMPTY;
261 if (!GetClientRect(This->hwnd, &rect))
262 return E_FAIL;
263 if (!ClientToScreen(This->hwnd, (POINT*)&rect) ||
264 !ClientToScreen(This->hwnd, &((POINT*)&rect)[1]))
265 return E_FAIL;
266 pt.x = x;
267 pt.y = y;
268 if (PtInRect(&rect, pt))
270 hr = AccessibleObjectFromWindow(This->hwnd, OBJID_CLIENT, &IID_IDispatch, (void**)&disp);
271 if (FAILED(hr))
272 return hr;
273 if (!disp)
274 return E_FAIL;
276 V_VT(v) = VT_DISPATCH;
277 V_DISPATCH(v) = disp;
278 return S_OK;
281 FIXME("non-client area not handled yet\n");
282 return E_NOTIMPL;
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));
289 return E_NOTIMPL;
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));
296 return E_NOTIMPL;
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));
303 return E_NOTIMPL;
306 static const IAccessibleVtbl WindowVtbl = {
307 Window_QueryInterface,
308 Window_AddRef,
309 Window_Release,
310 Window_GetTypeInfoCount,
311 Window_GetTypeInfo,
312 Window_GetIDsOfNames,
313 Window_Invoke,
314 Window_get_accParent,
315 Window_get_accChildCount,
316 Window_get_accChild,
317 Window_get_accName,
318 Window_get_accValue,
319 Window_get_accDescription,
320 Window_get_accRole,
321 Window_get_accState,
322 Window_get_accHelp,
323 Window_get_accHelpTopic,
324 Window_get_accKeyboardShortcut,
325 Window_get_accFocus,
326 Window_get_accSelection,
327 Window_get_accDefaultAction,
328 Window_accSelect,
329 Window_accLocation,
330 Window_accNavigate,
331 Window_accHitTest,
332 Window_accDoDefaultAction,
333 Window_put_accName,
334 Window_put_accValue
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);
366 *hwnd = This->hwnd;
367 return S_OK;
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);
374 return E_NOTIMPL;
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);
413 return E_NOTIMPL;
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);
420 return E_NOTIMPL;
423 static HRESULT WINAPI Window_EnumVARIANT_Reset(IEnumVARIANT *iface)
425 Window *This = impl_from_Window_EnumVARIANT(iface);
426 FIXME("(%p)\n", This);
427 return E_NOTIMPL;
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);
434 return E_NOTIMPL;
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 */
450 {NULL}
453 HRESULT create_window_object(HWND hwnd, const IID *iid, void **obj)
455 Window *window;
456 HRESULT hres;
458 if(!IsWindow(hwnd))
459 return E_FAIL;
461 window = heap_alloc_zero(sizeof(Window));
462 if(!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;
470 window->ref = 1;
471 window->hwnd = hwnd;
473 hres = IAccessible_QueryInterface(&window->IAccessible_iface, iid, obj);
474 IAccessible_Release(&window->IAccessible_iface);
475 return hres;