Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

789 lines
34 KiB

  1. //=============================================================================
  2. //
  3. // msaa.h -- Stub module that fakes Microsoft Active Accessibility APIs on
  4. // Win32 OSes without them.
  5. //
  6. // By using this header your code will be able to run on systems that do not
  7. // have updated versions of USER and GDI with Active Accessibility support, and
  8. // that do not have OLEACC.DLL installed. In those cases, you will get back
  9. // reasonable error codes for the following functions:
  10. // USER!BlockInput
  11. // USER!GetGUIThreadInfo
  12. // USER!GetWindowModuleFileName
  13. // USER!NotifyWinEvent
  14. // USER!SendInput
  15. // USER!SetWinEventHook
  16. // USER!UnhookWinEvent
  17. //
  18. // USER!GetCursorInfo
  19. // USER!GetWindowInfo
  20. // USER!GetTitleBarInfo
  21. // USER!GetScrollBarInfo
  22. // USER!GetComboBoxInfo
  23. // USER!GetAncestor
  24. // USER!RealChildWindowFromPoint
  25. // USER!RealGetWindowClass
  26. // USER!GetAltTabInfo
  27. // USER!GetListBoxInfo
  28. // USER!GetMenuBarInfo
  29. //
  30. // OLEACC!AccessibleChildren
  31. // OLEACC!AccessibleObjectFromEvent
  32. // OLEACC!AccessibleObjectFromPoint
  33. // OLEACC!AccessibleObjectFromWindow
  34. // OLEACC!CreateStdAccessibleObject
  35. // OLEACC!GetRoleText
  36. // OLEACC!GetStateText
  37. // OLEACC!LresultFromObject
  38. // OLEACC!ObjectFromLresult
  39. // OLEACC!WindowFromAccessibleObject
  40. //
  41. // Exactly one source must include this with COMPILE_MSAA_STUBS defined.
  42. //
  43. // Copyright (c) 1985-1997, Microsoft Corporation
  44. //
  45. //=============================================================================
  46. #ifdef __cplusplus
  47. extern "C" { // Assume C declarations for C++
  48. #endif // __cplusplus
  49. //
  50. // If we are building with Win95/NT4 headers, we need to declare
  51. // the msaa-related constants and APIs ourselves. We can do that
  52. // by including the files that come with the MSAA SDK.
  53. //
  54. #ifndef NO_WINABLE
  55. #ifndef INPUT
  56. #include <winable.h> // support for new USER API's (WinEvents,GetGuiThreadInfo,SendInput, etc.)
  57. #endif // INPUT not defined
  58. #endif // NO_WINABLE not defined
  59. #ifdef COMPILE_MSAA_STUBS
  60. #include <initguid.h>
  61. #endif
  62. #ifndef NO_OLEACC
  63. #ifndef ROLE_SYSTEM_TITLEBAR
  64. #include <oleacc.h> // support for IAccessible interface
  65. #endif // ROLE_SYSTEM_TITLEBAR not defined
  66. #endif // NO_OLEACC not defined
  67. // UnDefine these names so we can re-define them below.
  68. #undef BlockInput
  69. #undef GetGUIThreadInfo
  70. #undef GetWindowModuleFileName
  71. #undef NotifyWinEvent
  72. #undef SendInput
  73. #undef SetWinEventHook
  74. #undef UnhookWinEvent
  75. #undef GetCursorInfo
  76. #undef GetWindowInfo
  77. #undef GetTitleBarInfo
  78. #undef GetScrollBarInfo
  79. #undef GetComboBoxInfo
  80. #undef GetAncestor
  81. #undef RealChildWindowFromPoint
  82. #undef RealGetWindowClass
  83. #undef GetAltTabInfo
  84. #undef GetListBoxInfo
  85. #undef GetMenuBarInfo
  86. #undef AccessibleChildren
  87. #undef AccessibleObjectFromEvent
  88. #undef AccessibleObjectFromPoint
  89. #undef AccessibleObjectFromWindow
  90. #undef CreateStdAccessibleObject
  91. #undef GetRoleText
  92. #undef GetStateText
  93. #undef LresultFromObject
  94. #undef ObjectFromLresult
  95. #undef WindowFromAccessibleObject
  96. //
  97. // Define COMPILE_MSAA_STUBS to compile the stubs;
  98. // otherwise, you get the declarations.
  99. //
  100. #ifdef COMPILE_MSAA_STUBS
  101. //-----------------------------------------------------------------------------
  102. //
  103. // Implement the API stubs.
  104. //
  105. //-----------------------------------------------------------------------------
  106. #ifndef MSAA_FNS_DEFINED
  107. // USER
  108. BOOL (WINAPI* g_pfnBlockInput)(BOOL) = NULL;
  109. BOOL (WINAPI* g_pfnGetGUIThreadInfo)(DWORD,PGUITHREADINFO) = NULL;
  110. UINT (WINAPI* g_pfnGetWindowModuleFileName)(HWND,LPTSTR,UINT) = NULL;
  111. void (WINAPI* g_pfnNotifyWinEvent)(DWORD,HWND,LONG,LONG) = NULL;
  112. UINT (WINAPI* g_pfnSendInput)(UINT,LPINPUT,INT) = NULL;
  113. HWINEVENTHOOK (WINAPI* g_pfnSetWinEventHook)(UINT,UINT,HMODULE,WINEVENTPROC,DWORD,DWORD,UINT) = NULL;
  114. BOOL (WINAPI* g_pfnUnhookWinEvent)(HWINEVENTHOOK) = NULL;
  115. BOOL (WINAPI *g_pfnGetCursorInfo)(LPCURSORINFO) = NULL;
  116. BOOL (WINAPI *g_pfnGetWindowInfo)(HWND, LPWINDOWINFO) = NULL;
  117. BOOL (WINAPI *g_pfnGetTitleBarInfo)(HWND, LPTITLEBARINFO) = NULL;
  118. BOOL (WINAPI *g_pfnGetScrollBarInfo)(HWND, LONG, LPSCROLLBARINFO) = NULL;
  119. BOOL (WINAPI *g_pfnGetComboBoxInfo)(HWND, LPCOMBOBOXINFO) = NULL;
  120. HWND (WINAPI *g_pfnGetAncestor)(HWND, UINT) = NULL;
  121. HWND (WINAPI *g_pfnRealChildWindowFromPoint)(HWND, POINT) = NULL;
  122. UINT (WINAPI *g_pfnRealGetWindowClass)(HWND, LPTSTR, UINT) = NULL;
  123. BOOL (WINAPI *g_pfnGetAltTabInfo)(HWND, int, LPALTTABINFO, LPTSTR, UINT) = NULL;
  124. DWORD (WINAPI* g_pfnGetListBoxInfo)(HWND) = NULL;
  125. BOOL (WINAPI *g_pfnGetMenuBarInfo)(HWND, LONG, LONG, LPMENUBARINFO) = NULL;
  126. // OLEACC
  127. HRESULT (WINAPI* g_pfnAccessibleChildren)(IAccessible*,LONG,LONG,VARIANT*,LONG*) = NULL;
  128. HRESULT (WINAPI* g_pfnAccessibleObjectFromEvent)(HWND,DWORD,DWORD,IAccessible**,VARIANT*) = NULL;
  129. HRESULT (WINAPI* g_pfnAccessibleObjectFromPoint)(POINT,IAccessible**,VARIANT*) = NULL;
  130. HRESULT (WINAPI* g_pfnAccessibleObjectFromWindow)(HWND,DWORD,REFIID,void **) = NULL;
  131. HRESULT (WINAPI* g_pfnCreateStdAccessibleObject)(HWND,LONG,REFIID,void **) = NULL;
  132. UINT (WINAPI* g_pfnGetRoleText)(DWORD,LPTSTR,UINT) = NULL;
  133. UINT (WINAPI* g_pfnGetStateText)(DWORD,LPTSTR,UINT) = NULL;
  134. LRESULT (WINAPI* g_pfnLresultFromObject)(REFIID,WPARAM,LPUNKNOWN) = NULL;
  135. HRESULT (WINAPI* g_pfnObjectFromLresult)(LRESULT,REFIID,WPARAM,void**) = NULL;
  136. HRESULT (WINAPI* g_pfnWindowFromAccessibleObject)(IAccessible*,HWND*) = NULL;
  137. // STATUS
  138. BOOL g_fMSAAInitDone = FALSE;
  139. #endif
  140. //-----------------------------------------------------------------------------
  141. // This is the function that checks that all the required API's exist, and
  142. // then allows apps that include this file to call the real functions if they
  143. // exist, or the 'stubs' if they do not. This function is only called by the
  144. // stub functions - client code never needs to call this.
  145. //-----------------------------------------------------------------------------
  146. BOOL InitMSAAStubs(void)
  147. {
  148. HMODULE hUser32;
  149. HMODULE hOleacc;
  150. if (g_fMSAAInitDone)
  151. {
  152. return g_pfnBlockInput != NULL;
  153. }
  154. hOleacc = GetModuleHandle(TEXT("OLEACC.DLL"));
  155. if (!hOleacc)
  156. hOleacc = LoadLibrary(TEXT("OLEACC.DLL"));
  157. if ((hUser32 = GetModuleHandle(TEXT("USER32"))) &&
  158. (*(FARPROC*)&g_pfnBlockInput = GetProcAddress(hUser32,"BlockInput")) &&
  159. (*(FARPROC*)&g_pfnGetGUIThreadInfo = GetProcAddress(hUser32,"GetGUIThreadInfo")) &&
  160. (*(FARPROC*)&g_pfnNotifyWinEvent = GetProcAddress(hUser32,"NotifyWinEvent")) &&
  161. (*(FARPROC*)&g_pfnSendInput = GetProcAddress(hUser32,"SendInput")) &&
  162. (*(FARPROC*)&g_pfnSetWinEventHook = GetProcAddress(hUser32,"SetWinEventHook")) &&
  163. (*(FARPROC*)&g_pfnUnhookWinEvent = GetProcAddress(hUser32,"UnhookWinEvent")) &&
  164. (*(FARPROC*)&g_pfnGetCursorInfo = GetProcAddress(hUser32,"GetCursorInfo")) &&
  165. (*(FARPROC*)&g_pfnGetWindowInfo = GetProcAddress(hUser32,"GetWindowInfo")) &&
  166. (*(FARPROC*)&g_pfnGetTitleBarInfo = GetProcAddress(hUser32,"GetTitleBarInfo")) &&
  167. (*(FARPROC*)&g_pfnGetScrollBarInfo = GetProcAddress(hUser32,"GetScrollBarInfo")) &&
  168. (*(FARPROC*)&g_pfnGetComboBoxInfo = GetProcAddress(hUser32,"GetComboBoxInfo")) &&
  169. (*(FARPROC*)&g_pfnGetAncestor = GetProcAddress(hUser32,"GetAncestor")) &&
  170. (*(FARPROC*)&g_pfnRealChildWindowFromPoint = GetProcAddress(hUser32,"RealChildWindowFromPoint")) &&
  171. (*(FARPROC*)&g_pfnGetListBoxInfo = GetProcAddress(hUser32,"GetListBoxInfo")) &&
  172. (*(FARPROC*)&g_pfnGetMenuBarInfo = GetProcAddress(hUser32,"GetMenuBarInfo")) &&
  173. #ifdef UNICODE
  174. (*(FARPROC*)&g_pfnGetWindowModuleFileName = GetProcAddress(hUser32,"GetWindowModuleFileNameW")) &&
  175. (*(FARPROC*)&g_pfnRealGetWindowClass = GetProcAddress(hUser32,"RealGetWindowClassW")) &&
  176. (*(FARPROC*)&g_pfnGetAltTabInfo = GetProcAddress(hUser32,"GetAltTabInfoW")) &&
  177. #else
  178. (*(FARPROC*)&g_pfnGetWindowModuleFileName = GetProcAddress(hUser32,"GetWindowModuleFileNameA")) &&
  179. (*(FARPROC*)&g_pfnRealGetWindowClass = GetProcAddress(hUser32,"RealGetWindowClass")) &&
  180. (*(FARPROC*)&g_pfnGetAltTabInfo = GetProcAddress(hUser32,"GetAltTabInfo")) &&
  181. #endif
  182. (hOleacc) &&
  183. #ifdef UNICODE
  184. (*(FARPROC*)&g_pfnGetRoleText = GetProcAddress(hOleacc,"GetRoleTextW")) &&
  185. (*(FARPROC*)&g_pfnGetStateText = GetProcAddress(hOleacc,"GetStateTextW")) &&
  186. #else
  187. (*(FARPROC*)&g_pfnGetRoleText = GetProcAddress(hOleacc,"GetRoleTextA")) &&
  188. (*(FARPROC*)&g_pfnGetStateText = GetProcAddress(hOleacc,"GetStateTextA")) &&
  189. #endif
  190. (*(FARPROC*)&g_pfnAccessibleChildren = GetProcAddress(hOleacc,"AccessibleChildren")) &&
  191. (*(FARPROC*)&g_pfnAccessibleObjectFromEvent = GetProcAddress(hOleacc,"AccessibleObjectFromEvent")) &&
  192. (*(FARPROC*)&g_pfnAccessibleObjectFromPoint = GetProcAddress(hOleacc,"AccessibleObjectFromPoint")) &&
  193. (*(FARPROC*)&g_pfnAccessibleObjectFromWindow = GetProcAddress(hOleacc,"AccessibleObjectFromWindow")) &&
  194. (*(FARPROC*)&g_pfnCreateStdAccessibleObject = GetProcAddress(hOleacc,"CreateStdAccessibleObject")) &&
  195. (*(FARPROC*)&g_pfnLresultFromObject = GetProcAddress(hOleacc,"LresultFromObject")) &&
  196. (*(FARPROC*)&g_pfnObjectFromLresult = GetProcAddress(hOleacc,"ObjectFromLresult")) &&
  197. (*(FARPROC*)&g_pfnWindowFromAccessibleObject = GetProcAddress(hOleacc,"WindowFromAccessibleObject")) )
  198. {
  199. g_fMSAAInitDone = TRUE;
  200. return TRUE;
  201. }
  202. else
  203. {
  204. g_pfnBlockInput = NULL;
  205. g_pfnGetGUIThreadInfo = NULL;
  206. g_pfnGetWindowModuleFileName = NULL;
  207. g_pfnNotifyWinEvent = NULL;
  208. g_pfnSendInput = NULL;
  209. g_pfnSetWinEventHook = NULL;
  210. g_pfnUnhookWinEvent = NULL;
  211. g_pfnGetCursorInfo = NULL;
  212. g_pfnGetWindowInfo = NULL;
  213. g_pfnGetTitleBarInfo = NULL;
  214. g_pfnGetScrollBarInfo = NULL;
  215. g_pfnGetComboBoxInfo = NULL;
  216. g_pfnGetAncestor = NULL;
  217. g_pfnRealChildWindowFromPoint = NULL;
  218. g_pfnRealGetWindowClass = NULL;
  219. g_pfnGetAltTabInfo = NULL;
  220. g_pfnGetListBoxInfo = NULL;
  221. g_pfnGetMenuBarInfo = NULL;
  222. g_pfnAccessibleChildren = NULL;
  223. g_pfnAccessibleObjectFromEvent = NULL;
  224. g_pfnAccessibleObjectFromPoint = NULL;
  225. g_pfnAccessibleObjectFromWindow = NULL;
  226. g_pfnCreateStdAccessibleObject = NULL;
  227. g_pfnGetRoleText = NULL;
  228. g_pfnGetStateText = NULL;
  229. g_pfnLresultFromObject = NULL;
  230. g_pfnObjectFromLresult = NULL;
  231. g_pfnWindowFromAccessibleObject = NULL;
  232. g_fMSAAInitDone = TRUE;
  233. return FALSE;
  234. }
  235. }
  236. //-----------------------------------------------------------------------------
  237. //
  238. // Fake implementations of MSAA APIs that return error codes.
  239. // No special parameter validation is made since these run in client code
  240. //
  241. //-----------------------------------------------------------------------------
  242. //-----------------------------------------------------------------------------
  243. // Fake implementation of BlockInput. Always returns FALSE if API not present.
  244. //-----------------------------------------------------------------------------
  245. BOOL WINAPI xBlockInput (BOOL fBlock)
  246. {
  247. if (InitMSAAStubs())
  248. return g_pfnBlockInput(fBlock);
  249. return FALSE;
  250. }
  251. //-----------------------------------------------------------------------------
  252. // Fake implementation of GetGUIThreadInfo. Returns FALSE if API not present.
  253. //-----------------------------------------------------------------------------
  254. BOOL WINAPI xGetGUIThreadInfo (DWORD idThread,PGUITHREADINFO lpGuiThreadInfo)
  255. {
  256. if (InitMSAAStubs())
  257. return g_pfnGetGUIThreadInfo(idThread,lpGuiThreadInfo);
  258. lpGuiThreadInfo->flags = 0;
  259. lpGuiThreadInfo->hwndActive = NULL;
  260. lpGuiThreadInfo->hwndFocus = NULL;
  261. lpGuiThreadInfo->hwndCapture = NULL;
  262. lpGuiThreadInfo->hwndMenuOwner = NULL;
  263. lpGuiThreadInfo->hwndMoveSize = NULL;
  264. lpGuiThreadInfo->hwndCaret = NULL;
  265. return FALSE;
  266. }
  267. //-----------------------------------------------------------------------------
  268. // Fake implementation of GetWindowModuleFileName.
  269. //-----------------------------------------------------------------------------
  270. UINT WINAPI xGetWindowModuleFileName (HWND hWnd,LPTSTR lpszFileName,UINT cchFileNameMax)
  271. {
  272. if (InitMSAAStubs())
  273. return g_pfnGetWindowModuleFileName(hWnd,lpszFileName,cchFileNameMax);
  274. return 0;
  275. }
  276. //-----------------------------------------------------------------------------
  277. // Fake implementation of NotifyWinEvent
  278. //-----------------------------------------------------------------------------
  279. void xNotifyWinEvent (DWORD dwEvent,HWND hWnd,LONG idObject,LONG idChild)
  280. {
  281. if (InitMSAAStubs())
  282. g_pfnNotifyWinEvent(dwEvent,hWnd,idObject,idChild);
  283. return;
  284. }
  285. //-----------------------------------------------------------------------------
  286. // Fake implementation of SendInput. Always returns 0 if API not present.
  287. //-----------------------------------------------------------------------------
  288. UINT WINAPI xSendInput (UINT cInputs,LPINPUT lpInput,INT cbSize)
  289. {
  290. if (InitMSAAStubs())
  291. return g_pfnSendInput (cInputs,lpInput,cbSize);
  292. return 0;
  293. }
  294. //-----------------------------------------------------------------------------
  295. // Fake implementation of SetWinEventHook. Returns NULL if API not present.
  296. //-----------------------------------------------------------------------------
  297. HWINEVENTHOOK WINAPI xSetWinEventHook (UINT eventMin,UINT eventMax,
  298. HMODULE hModWinEventHook,
  299. WINEVENTPROC lpfnWinEventProc,
  300. DWORD idProcess,DWORD idThread,
  301. UINT dwFlags)
  302. {
  303. if (InitMSAAStubs())
  304. return g_pfnSetWinEventHook (eventMin,eventMax,hModWinEventHook,
  305. lpfnWinEventProc,idProcess,idThread,dwFlags);
  306. return NULL;
  307. }
  308. //-----------------------------------------------------------------------------
  309. // Fake implementation of UnhookWinEvent. Returns FALSE if API not present.
  310. //-----------------------------------------------------------------------------
  311. BOOL WINAPI xUnhookWinEvent (HWINEVENTHOOK hWinEventHook)
  312. {
  313. if (InitMSAAStubs())
  314. return g_pfnUnhookWinEvent (hWinEventHook);
  315. return FALSE;
  316. }
  317. //-----------------------------------------------------------------------------
  318. // Fake implementation of GetCursorInfo. Returns FALSE if API not present.
  319. //-----------------------------------------------------------------------------
  320. BOOL WINAPI xGetCursorInfo(LPCURSORINFO lpCursorInfo)
  321. {
  322. if (InitMSAAStubs())
  323. return g_pfnGetCursorInfo(lpCursorInfo);
  324. return FALSE;
  325. }
  326. //-----------------------------------------------------------------------------
  327. // Fake implementation of GetWindowInfo. Returns TRUE if API not present, but
  328. // not all the fields are correctly filled in.
  329. //-----------------------------------------------------------------------------
  330. BOOL WINAPI xGetWindowInfo(HWND hwnd, LPWINDOWINFO lpwi)
  331. {
  332. if (InitMSAAStubs())
  333. return g_pfnGetWindowInfo(hwnd,lpwi);
  334. // this is an incomplete implementation of GetWindowInfo
  335. GetWindowRect(hwnd,&lpwi->rcWindow);
  336. GetClientRect(hwnd,&lpwi->rcClient);
  337. lpwi->dwStyle = GetWindowLong (hwnd,GWL_STYLE);
  338. lpwi->dwExStyle = GetWindowLong (hwnd,GWL_EXSTYLE);
  339. lpwi->dwWindowsState = 0; // should have WS_ACTIVECAPTION in here if active
  340. lpwi->cxWindowBorders = 0; // wrong
  341. lpwi->cyWindowBorders = 0; // wrong
  342. lpwi->atomWindowType = 0; // wrong
  343. lpwi->wCreatorVersion = 0; // wrong
  344. return TRUE;
  345. }
  346. //-----------------------------------------------------------------------------
  347. // Fake implementation of GetTitleBarInfo. Returns FALSE if API not present.
  348. //-----------------------------------------------------------------------------
  349. BOOL WINAPI xGetTitleBarInfo(HWND hwnd, LPTITLEBARINFO lpTitleBarInfo)
  350. {
  351. if (InitMSAAStubs())
  352. return g_pfnGetTitleBarInfo(hwnd,lpTitleBarInfo);
  353. return FALSE;
  354. }
  355. //-----------------------------------------------------------------------------
  356. // Fake implementation of GetScrollBarInfo. Returns FALSE if API not present.
  357. //-----------------------------------------------------------------------------
  358. BOOL WINAPI xGetScrollBarInfo(HWND hwnd, LONG idObject, LPSCROLLBARINFO lpScrollBarInfo)
  359. {
  360. if (InitMSAAStubs())
  361. return g_pfnGetScrollBarInfo(hwnd,idObject,lpScrollBarInfo);
  362. return FALSE;
  363. }
  364. //-----------------------------------------------------------------------------
  365. // Fake implementation of GetComboBoxInfo. Returns if API not present.
  366. //-----------------------------------------------------------------------------
  367. BOOL WINAPI xGetComboBoxInfo(HWND hwnd, LPCOMBOBOXINFO lpComboBoxInfo)
  368. {
  369. if (InitMSAAStubs())
  370. return g_pfnGetComboBoxInfo(hwnd,lpComboBoxInfo);
  371. return FALSE;
  372. }
  373. //-----------------------------------------------------------------------------
  374. // Fake implementation of GetAncestor. If API not present, this will try to
  375. // do what the real implementation does.
  376. //-----------------------------------------------------------------------------
  377. HWND WINAPI xGetAncestor(HWND hwnd, UINT gaFlags)
  378. {
  379. HWND hwndParent;
  380. HWND hwndDesktop;
  381. DWORD dwStyle;
  382. if (InitMSAAStubs())
  383. return g_pfnGetAncestor(hwnd,gaFlags);
  384. // HERE IS THE FAKE IMPLEMENTATION
  385. if (!IsWindow(hwnd))
  386. return(NULL);
  387. if ((gaFlags < GA_MIC) || (gaFlags > GA_MAC))
  388. return(NULL);
  389. hwndDesktop = GetDesktopWindow();
  390. if (hwnd == hwndDesktop)
  391. return(NULL);
  392. dwStyle = GetWindowLong (hwnd,GWL_STYLE);
  393. switch (gaFlags)
  394. {
  395. case GA_PARENT:
  396. if (dwStyle & WS_CHILD)
  397. hwndParent = GetParent(hwnd);
  398. else
  399. hwndParent = GetWindow (hwnd,GW_OWNER);
  400. if (hwndParent == NULL)
  401. hwndParent = hwnd;
  402. break;
  403. case GA_ROOT:
  404. if (dwStyle & WS_CHILD)
  405. hwndParent = GetParent(hwnd);
  406. else
  407. hwndParent = GetWindow (hwnd,GW_OWNER);
  408. while (hwndParent != hwndDesktop &&
  409. hwndParent != NULL)
  410. {
  411. hwnd = hwndParent;
  412. dwStyle = GetWindowLong(hwnd,GWL_STYLE);
  413. if (dwStyle & WS_CHILD)
  414. hwndParent = GetParent(hwnd);
  415. else
  416. hwndParent = GetWindow (hwnd,GW_OWNER);
  417. }
  418. break;
  419. case GA_ROOTOWNER:
  420. while (hwndParent = GetParent(hwnd))
  421. hwnd = hwndParent;
  422. break;
  423. }
  424. return(hwndParent);
  425. }
  426. //-----------------------------------------------------------------------------
  427. // Fake implementation of RealChildWindowFromPoint. Returns NULL if API not present.
  428. //-----------------------------------------------------------------------------
  429. HWND WINAPI xRealChildWindowFromPoint(HWND hwnd, POINT pt)
  430. {
  431. if (InitMSAAStubs())
  432. return g_pfnRealChildWindowFromPoint(hwnd,pt);
  433. return (NULL);
  434. }
  435. //-----------------------------------------------------------------------------
  436. // Fake implementation of RealGetWindowClass. Returns regular ClassName if API
  437. // not present.
  438. //-----------------------------------------------------------------------------
  439. UINT WINAPI xRealGetWindowClass(HWND hwnd, LPTSTR lpszClass, UINT cchMax)
  440. {
  441. if (InitMSAAStubs())
  442. return g_pfnRealGetWindowClass(hwnd,lpszClass,cchMax);
  443. #ifdef UNICODE
  444. return (GetClassNameW(hwnd,lpszClass,cchMax));
  445. #else
  446. return (GetClassName(hwnd,lpszClass,cchMax));
  447. #endif
  448. }
  449. //-----------------------------------------------------------------------------
  450. // Fake implementation of GetAltTabInfo. Returns FALSE if API not present.
  451. //-----------------------------------------------------------------------------
  452. BOOL WINAPI xGetAltTabInfo(HWND hwnd,int iItem,LPALTTABINFO lpati,LPTSTR lpszItemText,UINT cchItemText)
  453. {
  454. if (InitMSAAStubs())
  455. return g_pfnGetAltTabInfo(hwnd,iItem,lpati,lpszItemText,cchItemText);
  456. return FALSE;
  457. }
  458. //-----------------------------------------------------------------------------
  459. // Fake implementation of GetListBoxInfo. Returns FALSE if API not present.
  460. //-----------------------------------------------------------------------------
  461. DWORD WINAPI xGetListBoxInfo(HWND hwnd)
  462. {
  463. if (InitMSAAStubs())
  464. return g_pfnGetListBoxInfo(hwnd);
  465. return FALSE;
  466. }
  467. //-----------------------------------------------------------------------------
  468. // Fake implementation of GetMenuBarInfo. Returns FALSE if API not present.
  469. //-----------------------------------------------------------------------------
  470. BOOL WINAPI xGetMenuBarInfo(HWND hwnd, long idObject, long idItem, LPMENUBARINFO lpmbi)
  471. {
  472. if (InitMSAAStubs())
  473. return g_pfnGetMenuBarInfo(hwnd,idObject,idItem,lpmbi);
  474. return FALSE;
  475. }
  476. //-----------------------------------------------------------------------------
  477. // Fake implementation of AccessibleChildren. Returns E_NOTIMPL if API not present.
  478. //-----------------------------------------------------------------------------
  479. HRESULT xAccessibleChildren (IAccessible* paccContainer,LONG iChildStart,
  480. LONG cChildren,VARIANT* rgvarChildren,LONG* pcObtained)
  481. {
  482. if (InitMSAAStubs())
  483. return g_pfnAccessibleChildren (paccContainer,iChildStart,cChildren,
  484. rgvarChildren,pcObtained);
  485. return (E_NOTIMPL);
  486. }
  487. //-----------------------------------------------------------------------------
  488. // Fake implementation of AccessibleObjectFromEvent. Returns E_NOTIMPL if the
  489. // real API is not present.
  490. //-----------------------------------------------------------------------------
  491. HRESULT WINAPI xAccessibleObjectFromEvent (HWND hWnd,DWORD dwID,DWORD dwChild,
  492. IAccessible** ppacc,VARIANT*pvarChild)
  493. {
  494. if (InitMSAAStubs())
  495. return g_pfnAccessibleObjectFromEvent (hWnd,dwID,dwChild,ppacc,pvarChild);
  496. return (E_NOTIMPL);
  497. }
  498. //-----------------------------------------------------------------------------
  499. // Fake implementation of AccessibleObjectFromPoint. Returns E_NOTIMPL if the
  500. // real API is not present.
  501. //-----------------------------------------------------------------------------
  502. HRESULT WINAPI xAccessibleObjectFromPoint (POINT ptScreen,IAccessible** ppacc,
  503. VARIANT* pvarChild)
  504. {
  505. if (InitMSAAStubs())
  506. return g_pfnAccessibleObjectFromPoint (ptScreen,ppacc,pvarChild);
  507. return (E_NOTIMPL);
  508. }
  509. //-----------------------------------------------------------------------------
  510. // Fake implementation of AccessibleObjectFromWindow. Returns E_NOTIMPL if the
  511. // real API is not present.
  512. //-----------------------------------------------------------------------------
  513. HRESULT WINAPI xAccessibleObjectFromWindow (HWND hWnd,DWORD dwID,REFIID riidInterface,
  514. void ** ppvObject)
  515. {
  516. if (InitMSAAStubs())
  517. return g_pfnAccessibleObjectFromWindow (hWnd,dwID,riidInterface,ppvObject);
  518. return (E_NOTIMPL);
  519. }
  520. //-----------------------------------------------------------------------------
  521. // Fake implementation of CreateStdAccessibleObject. Returns E_NOTIMPL if the
  522. // real API is not present.
  523. //-----------------------------------------------------------------------------
  524. HRESULT WINAPI xCreateStdAccessibleObject (HWND hWnd,LONG dwID,REFIID riidInterface,
  525. void ** ppvObject)
  526. {
  527. if (InitMSAAStubs())
  528. return g_pfnCreateStdAccessibleObject (hWnd,dwID,riidInterface,ppvObject);
  529. return (E_NOTIMPL);
  530. }
  531. //-----------------------------------------------------------------------------
  532. // Fake implementation of GetRoleText. Returns 0 if real API not present.
  533. //-----------------------------------------------------------------------------
  534. UINT WINAPI xGetRoleText (DWORD dwRole,LPTSTR lpszRole,UINT cchRoleMax)
  535. {
  536. if (InitMSAAStubs())
  537. return g_pfnGetRoleText (dwRole,lpszRole,cchRoleMax);
  538. return (0);
  539. }
  540. //-----------------------------------------------------------------------------
  541. // Fake implementation of GetStateText. Returns 0 if real API not present.
  542. //-----------------------------------------------------------------------------
  543. UINT WINAPI xGetStateText (DWORD dwState,LPTSTR lpszState,UINT cchStateMax)
  544. {
  545. if (InitMSAAStubs())
  546. return g_pfnGetStateText (dwState,lpszState,cchStateMax);
  547. return (0);
  548. }
  549. //-----------------------------------------------------------------------------
  550. // Fake implementation of LresultFromObject. Returns E_NOTIMPL if the real API
  551. // is not present.
  552. //-----------------------------------------------------------------------------
  553. LRESULT WINAPI xLresultFromObject (REFIID riidInterface,WPARAM wParam,LPUNKNOWN pUnk)
  554. {
  555. if (InitMSAAStubs())
  556. return g_pfnLresultFromObject (riidInterface,wParam,pUnk);
  557. return (E_NOTIMPL);
  558. }
  559. //-----------------------------------------------------------------------------
  560. // Fake implementation of ObjectFromLresult. Returns E_NOTIMPL if the
  561. // real API is not present.
  562. //-----------------------------------------------------------------------------
  563. HRESULT WINAPI xObjectFromLresult (LRESULT lResult,REFIID riidInterface,WPARAM wParam,
  564. void** ppvObject)
  565. {
  566. if (InitMSAAStubs())
  567. return g_pfnObjectFromLresult (lResult,riidInterface,wParam,ppvObject);
  568. return (E_NOTIMPL);
  569. }
  570. //-----------------------------------------------------------------------------
  571. // Fake implementation of WindowFromAccessibleObject. Returns E_NOTIMPL if the
  572. // real API is not present.
  573. //-----------------------------------------------------------------------------
  574. HRESULT WINAPI xWindowFromAccessibleObject (IAccessible* pAcc,HWND* phWnd)
  575. {
  576. if (InitMSAAStubs())
  577. return g_pfnWindowFromAccessibleObject (pAcc,phWnd);
  578. return (E_NOTIMPL);
  579. }
  580. #undef COMPILE_MSAA_STUBS
  581. #else // COMPILE_MSAA_STUBS
  582. extern BOOL WINAPI xBlockInput (BOOL fBlock);
  583. extern BOOL WINAPI xGetGUIThreadInfo (DWORD idThread,
  584. PGUITHREADINFO lpGuiThreadInfo);
  585. extern UINT WINAPI xGetWindowModuleFileName (HWND hWnd,
  586. LPTSTR lpszFileName,
  587. UINT cchFileNameMax);
  588. extern void WINAPI xNotifyWinEvent (DWORD dwEvent,
  589. HWND hWnd,
  590. LONG idObject,
  591. LONG idChild);
  592. extern UINT WINAPI xSendInput (UINT cInputs,
  593. LPINPUT lpInput,
  594. INT cbSize);
  595. extern HWINEVENTHOOK WINAPI xSetWinEventHook (DWORD eventMin,
  596. DWORD eventMax,
  597. HMODULE hModWinEventHook,
  598. WINEVENTPROC lpfnWinEventProc,
  599. DWORD idProcess,
  600. DWORD idThread,
  601. DWORD dwFlags);
  602. extern BOOL WINAPI xUnhookWinEvent (HWINEVENTHOOK hWinEventHook);
  603. extern BOOL WINAPI xGetCursorInfo (LPCURSORINFO lpCursorInfo);
  604. extern BOOL WINAPI xGetWindowInfo (HWND hwnd,
  605. LPWINDOWINFO lpwi);
  606. extern BOOL WINAPI xGetTitleBarInfo (HWND hwnd,
  607. LPTITLEBARINFO lpTitleBarInfo);
  608. extern BOOL WINAPI xGetScrollBarInfo (HWND hwnd,
  609. LONG idObject,
  610. LPSCROLLBARINFO lpScrollBarInfo);
  611. extern BOOL WINAPI xGetComboBoxInfo (HWND hwnd,
  612. LPCOMBOBOXINFO lpComboBoxInfo);
  613. extern HWND WINAPI xGetAncestor (HWND hwnd,
  614. UINT gaFlags);
  615. extern HWND WINAPI xRealChildWindowFromPoint (HWND hwnd,
  616. POINT pt);
  617. extern UINT WINAPI xRealGetWindowClass (HWND hwnd,
  618. LPTSTR lpszClass,
  619. UINT cchMax);
  620. extern BOOL WINAPI xGetAltTabInfo (HWND hwnd,
  621. int iItem,
  622. LPALTTABINFO lpati,
  623. LPTSTR lpszItemText,
  624. UINT cchItemText);
  625. extern DWORD WINAPI xGetListBoxInfo (HWND hwnd);
  626. extern BOOL WINAPI xGetMenuBarInfo (HWND hwnd,
  627. long idObject,
  628. long idItem,
  629. LPMENUBARINFO lpmbi);
  630. extern HRESULT WINAPI xAccessibleChildren (IAccessible* paccContainer,
  631. LONG iChildStart,
  632. LONG cChildren,
  633. VARIANT* rgvarChildren,
  634. LONG* pcObtained);
  635. extern HRESULT WINAPI xAccessibleObjectFromEvent (HWND hWnd,
  636. DWORD dwID,
  637. DWORD dwChild,
  638. IAccessible** ppacc,
  639. VARIANT*pvarChild);
  640. extern HRESULT WINAPI xAccessibleObjectFromPoint (POINT ptScreen,
  641. IAccessible** ppacc,
  642. VARIANT* pvarChild);
  643. extern HRESULT WINAPI xAccessibleObjectFromWindow (HWND hWnd,
  644. DWORD dwID,
  645. REFIID riidInterface,
  646. void ** ppvObject);
  647. extern HRESULT WINAPI xCreateStdAccessibleObject (HWND hWnd,
  648. LONG dwID,
  649. REFIID riidInterface,
  650. void ** ppvObject);
  651. extern UINT WINAPI xGetRoleText (DWORD dwRole,
  652. LPTSTR lpszRole,
  653. UINT cchRoleMax);
  654. extern UINT WINAPI xGetStateText (DWORD dwState,
  655. LPTSTR lpszState,
  656. UINT cchStateMax);
  657. extern LRESULT WINAPI xLresultFromObject (REFIID riidInterface,
  658. WPARAM wParam,
  659. LPUNKNOWN pUnk);
  660. extern HRESULT WINAPI xObjectFromLresult (LRESULT lResult,
  661. REFIID riidInterface,
  662. WPARAM wParam,
  663. void** ppvObject);
  664. extern HRESULT WINAPI xWindowFromAccessibleObject (IAccessible* pAcc,
  665. HWND* phWnd);
  666. #endif // COMPILE_MSAA_STUBS
  667. //
  668. // build defines that replace the regular APIs with our versions
  669. //
  670. #define BlockInput xBlockInput
  671. #define GetGUIThreadInfo xGetGUIThreadInfo
  672. #define GetWindowModuleFileName xGetWindowModuleFileName
  673. #define NotifyWinEvent xNotifyWinEvent
  674. #define SendInput xSendInput
  675. #define SetWinEventHook xSetWinEventHook
  676. #define UnhookWinEvent xUnhookWinEvent
  677. #define GetCursorInfo xGetCursorInfo
  678. #define GetWindowInfo xGetWindowInfo
  679. #define GetTitleBarInfo xGetTitleBarInfo
  680. #define GetScrollBarInfo xGetScrollBarInfo
  681. #define GetComboBoxInfo xGetComboBoxInfo
  682. #define GetAncestor xGetAncestor
  683. #define RealChildWindowFromPoint xRealChildWindowFromPoint
  684. #define RealGetWindowClass xRealGetWindowClass
  685. #define GetAltTabInfo xGetAltTabInfo
  686. #define GetListBoxInfo xGetListBoxInfo
  687. #define GetMenuBarInfo xGetMenuBarInfo
  688. #define AccessibleChildren xAccessibleChildren
  689. #define AccessibleObjectFromEvent xAccessibleObjectFromEvent
  690. #define AccessibleObjectFromPoint xAccessibleObjectFromPoint
  691. #define AccessibleObjectFromWindow xAccessibleObjectFromWindow
  692. #define CreateStdAccessibleObject xCreateStdAccessibleObject
  693. #define GetRoleText xGetRoleText
  694. #define GetStateText xGetStateText
  695. #define LresultFromObject xLresultFromObject
  696. #define ObjectFromLresult xObjectFromLresult
  697. #define WindowFromAccessibleObject xWindowFromAccessibleObject
  698. #ifdef __cplusplus
  699. }
  700. #endif // __cplusplus