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.

1932 lines
60 KiB

  1. //
  2. //
  3. //
  4. #include "private.h"
  5. #include "globals.h"
  6. #include "utbacc.h"
  7. //
  8. //
  9. //
  10. typedef void (*LPFNNOTIFYWINEVENT)( DWORD, HWND, LONG, LONG );
  11. static LPFNNOTIFYWINEVENT g_lpfnNotifyWinEvent = NULL;
  12. //////////////////////////////////////////////////////////////////////////////
  13. //
  14. // misc func
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17. //----------------------------------------------------------------------------
  18. //
  19. // InitTipbarAcc
  20. //
  21. //----------------------------------------------------------------------------
  22. void InitTipbarAcc( void )
  23. {
  24. HMODULE hLibUser32 = NULL;
  25. if (g_lpfnNotifyWinEvent)
  26. return;
  27. //
  28. // load libs
  29. //
  30. hLibUser32 = GetSystemModuleHandle( "user32.dll" );
  31. if (!hLibUser32)
  32. return;
  33. //
  34. // get proc address
  35. //
  36. g_lpfnNotifyWinEvent = (LPFNNOTIFYWINEVENT)GetProcAddress( hLibUser32, "NotifyWinEvent" );
  37. }
  38. //----------------------------------------------------------------------------
  39. //
  40. // OurNotifyWinEvent
  41. //
  42. //----------------------------------------------------------------------------
  43. static __inline void OurNotifyWinEvent( DWORD event, HWND hWnd, LONG idObject, LONG idChild )
  44. {
  45. if (g_lpfnNotifyWinEvent)
  46. {
  47. g_lpfnNotifyWinEvent( event, hWnd, idObject, idChild );
  48. }
  49. }
  50. //////////////////////////////////////////////////////////////////////////////
  51. //
  52. // CTipbarAccessible
  53. //
  54. //////////////////////////////////////////////////////////////////////////////
  55. //----------------------------------------------------------------------------
  56. //
  57. // ctor
  58. //
  59. //----------------------------------------------------------------------------
  60. CTipbarAccessible::CTipbarAccessible( CTipbarAccItem *pAccItemSelf )
  61. {
  62. CTipbarAccItem **ppItem;
  63. _cRef = 1;
  64. _hWnd = NULL;
  65. _pTypeInfo = NULL;
  66. _pDefAccClient = NULL;
  67. _fInitialized = FALSE;
  68. _lSelection = 1;
  69. // register itself
  70. ppItem = _rgAccItems.Append(1);
  71. if (ppItem)
  72. *ppItem = pAccItemSelf;
  73. //
  74. // thread safe? yes.
  75. // this object is created on only thread with CTipbarWnd..
  76. //
  77. g_DllRefCount++;
  78. }
  79. //----------------------------------------------------------------------------
  80. //
  81. // dtor
  82. //
  83. //----------------------------------------------------------------------------
  84. CTipbarAccessible::~CTipbarAccessible( void )
  85. {
  86. SafeReleaseClear( _pTypeInfo );
  87. SafeReleaseClear( _pDefAccClient );
  88. //
  89. // thread safe? yes.
  90. // this object is created on only thread with CTipbarWnd..
  91. //
  92. g_DllRefCount--;
  93. }
  94. //----------------------------------------------------------------------------
  95. //
  96. // SetWindow
  97. //
  98. //----------------------------------------------------------------------------
  99. void CTipbarAccessible::SetWindow( HWND hWnd )
  100. {
  101. _hWnd = hWnd;
  102. }
  103. //-----------------------------------------------------------------------
  104. //
  105. // Initialize()
  106. //
  107. // DESCRIPTION:
  108. //
  109. // Initializes the state of the CTipbarAccessible object, performing
  110. // tasks that might normally be done in a class constructor but
  111. // are done here to trap any errors.
  112. //
  113. // PARAMETERS:
  114. //
  115. // hWnd Handle to the HWND object with which this
  116. // Accessible object is associated. This
  117. // is the handle to our main window.
  118. //
  119. // hInst Instance handle for this instance of the
  120. // application.
  121. //
  122. // RETURNS:
  123. //
  124. // HRESULT NOERROR if the CTipbarAccessible object is
  125. // initialized successfully, a COM error
  126. // code otherwise.
  127. //
  128. // NOTES:
  129. //
  130. // It is assumed that this method will be called for the object
  131. // immediately after and only after the object is constructed.
  132. //
  133. // ----------------------------------------------------------------------
  134. HRESULT CTipbarAccessible::Initialize( void )
  135. {
  136. HRESULT hr;
  137. ITypeLib *piTypeLib;
  138. _fInitialized = TRUE;
  139. //
  140. // For our client window, create a system provided
  141. // Accessible object which implements the default
  142. // client window Accessibility behavior.
  143. //
  144. // Our implementation of CTipbarAccessible will use the
  145. // default object's implementation as needed. In
  146. // essence, CTipbarAccessible "inherits" its functionality
  147. // from the standard object, "customizing" or
  148. // "overriding" various methods for which the
  149. // standard implementation is insufficent for the
  150. // specifics of the window for which CTipbarAccessible
  151. // provides Accessibility.
  152. //
  153. hr = CreateStdAccessibleObject( _hWnd,
  154. OBJID_CLIENT,
  155. IID_IAccessible,
  156. (void **) &_pDefAccClient );
  157. if (FAILED(hr))
  158. {
  159. return hr;
  160. }
  161. //
  162. // Obtain an ITypeInfo pointer to our type library.
  163. // The ITypeInfo pointer is used to implement the
  164. // IDispatch interface.
  165. //
  166. //
  167. // First, attempt to load the Accessibility type
  168. // library version 1.0 using the registry.
  169. //
  170. hr = LoadRegTypeLib( LIBID_Accessibility, 1, 0, 0, &piTypeLib );
  171. //
  172. // If we fail to load the type library from the
  173. // registry information, explicitly try to load
  174. // it from the MSAA system DLL.
  175. //
  176. if (FAILED(hr))
  177. {
  178. static OLECHAR s_szOleAcc[] = L"OLEACC.DLL";
  179. hr = LoadTypeLib( s_szOleAcc, &piTypeLib );
  180. }
  181. //
  182. // If we successfully load the type library, attempt
  183. // to get the IAccessible type description
  184. // (ITypeInfo pointer) from the type library.
  185. //
  186. if (SUCCEEDED(hr))
  187. {
  188. hr = piTypeLib->GetTypeInfoOfGuid( IID_IAccessible, &_pTypeInfo );
  189. piTypeLib->Release();
  190. }
  191. return hr;
  192. }
  193. //-----------------------------------------------------------------------
  194. //
  195. // QueryInterface()
  196. //
  197. // DESCRIPTION:
  198. //
  199. // Implements the IUnknown interface method QueryInterface().
  200. //
  201. // PARAMETERS:
  202. //
  203. // riid [in] The requested interface's IID.
  204. // ppv [out] If the requested interface is supported,
  205. // ppv points to the location of a pointer
  206. // to the requested interface. If the
  207. // requested interface is not supported,
  208. // ppv is set to NULL.
  209. //
  210. // RETURNS:
  211. //
  212. // HRESULT S_OK if the interface is supported,
  213. // E_NOINTERFACE if the interface is not
  214. // supported, or some other COM error
  215. // if the IEnumVARIANT interface is requested
  216. // but cannot be delivered.
  217. //
  218. // NOTES:
  219. //
  220. // CTipbarAccessible correctly supports the IUnknown, IDispatch and
  221. // IAccessible interfaces. CTipbarAccessible also incorrectly supports
  222. // the IEnumVARIANT interface (to return a VARIANT enumerator
  223. // containing all its children). When the IEnumVARIANT
  224. // interface is requested, an enumerator is created and a
  225. // pointer to its IEnumVARIANT interface is returned.
  226. //
  227. // The support for IEnumVARIANT is incorrect because the
  228. // interface pointer returned is not symmetric with respect
  229. // to the interface from which it was obtained. For example,
  230. // assume that pIA is a pointer to an IAccessible interface.
  231. // Then, even though pIA->QueryInterface(IID_IEnumVARIANT)
  232. // succeeds and returns pIEV,
  233. // pIEV->QueryInterface(IID_Accessibility) will fail because
  234. // the enumerator has no knowledge of any interface except
  235. // itself (and IUnknown).
  236. //
  237. // The original design of MSAA called for IAccessible
  238. // objects to also be enumerators of their children. But
  239. // this design doesn't allow for different clients of the
  240. // Accessible object to have different enumerations of its
  241. // children and that is a potentially hazardous situation.
  242. // (Assume there is an Accessible object that is also a
  243. // VARIANT enumerator, A, and two clients, C1 and C2.
  244. // Since C1 and C2 each may be pre-empted will using A,
  245. // the following is a one of many examples that would pose
  246. // a problem for at least one client:
  247. //
  248. // C1: A->Reset()
  249. // C1: A->Skip( 5 )
  250. // C2: A->Reset()
  251. // C1: A->Next() ! C1 does not get the child it expects
  252. //
  253. // So, although it breaks the rules of COM, QueryInterface()
  254. // as implemented below obtains a distinct VARIANT enumerator
  255. // for each request. A better solution to this issue would
  256. // be if the IAccessible interface provided a method to get
  257. // the child enumeration or if MSAA provided an exported API
  258. // to perform this task.
  259. //
  260. // ----------------------------------------------------------------------
  261. STDMETHODIMP CTipbarAccessible::QueryInterface( REFIID riid, void** ppv )
  262. {
  263. *ppv = NULL;
  264. //
  265. // If the IUnknown, IDispatch, or IAccessible
  266. // interface is desired, simply cast the this
  267. // pointer appropriately.
  268. //
  269. if ( riid == IID_IUnknown )
  270. {
  271. *ppv = (LPUNKNOWN) this;
  272. }
  273. else if ( riid == IID_IDispatch )
  274. {
  275. *ppv = (IDispatch *) this;
  276. }
  277. else if ( riid == IID_IAccessible )
  278. {
  279. *ppv = (IAccessible *)this;
  280. }
  281. #ifdef NEVER
  282. //
  283. // If the IEnumVARIANT interface is desired, create
  284. // a new VARIANT enumerator which contains all
  285. // the Accessible object's children.
  286. //
  287. else if (riid == IID_IEnumVARIANT)
  288. {
  289. CEnumVariant* pcenum;
  290. HRESULT hr;
  291. hr = CreateVarEnumOfAllChildren( &pcenum );
  292. if ( FAILED( hr ) )
  293. return hr;
  294. *ppv = (IEnumVARIANT *) pcenum;
  295. }
  296. #endif /* NEVER */
  297. //
  298. // If the desired interface isn't one we know about,
  299. // return E_NOINTERFACE.
  300. //
  301. else
  302. {
  303. return E_NOINTERFACE;
  304. }
  305. //
  306. // Increase the reference count of any interface
  307. // returned.
  308. //
  309. ((LPUNKNOWN) *ppv)->AddRef();
  310. return S_OK;
  311. }
  312. //-----------------------------------------------------------------------
  313. //
  314. // AddRef()
  315. //
  316. // DESCRIPTION:
  317. //
  318. // Implements the IUnknown interface method AddRef().
  319. //
  320. // PARAMETERS:
  321. //
  322. // None.
  323. //
  324. // RETURNS:
  325. //
  326. // ULONG Current reference count.
  327. //
  328. // NOTES:
  329. //
  330. // The lifetime of the Accessible object is governed by the
  331. // lifetime of the HWND object for which it provides
  332. // Accessibility. The object is created in response to the
  333. // first WM_GETOBJECT message that the server application
  334. // is ready to process and is destroyed when the server's
  335. // main window is destroyed. Since the object's lifetime
  336. // is not dependent on a reference count, the object has no
  337. // internal mechanism for tracking reference counting and
  338. // AddRef() and Release() always return one.
  339. //
  340. //-----------------------------------------------------------------------
  341. STDMETHODIMP_(ULONG) CTipbarAccessible::AddRef( void )
  342. {
  343. return InterlockedIncrement( &_cRef );
  344. }
  345. //-----------------------------------------------------------------------
  346. //
  347. // Release()
  348. //
  349. // DESCRIPTION:
  350. //
  351. // Implements the IUnknown interface method Release().
  352. //
  353. // PARAMETERS:
  354. //
  355. // None.
  356. //
  357. // RETURNS:
  358. //
  359. // ULONG Current reference count.
  360. //
  361. // NOTES:
  362. //
  363. // The lifetime of the Accessible object is governed by the
  364. // lifetime of the HWND object for which it provides
  365. // Accessibility. The object is created in response to the
  366. // first WM_GETOBJECT message that the server application
  367. // is ready to process and is destroyed when the server's
  368. // main window is destroyed. Since the object's lifetime
  369. // is not dependent on a reference count, the object has no
  370. // internal mechanism for tracking reference counting and
  371. // AddRef() and Release() always return one.
  372. //
  373. //-----------------------------------------------------------------------
  374. STDMETHODIMP_(ULONG) CTipbarAccessible::Release( void )
  375. {
  376. ULONG l = InterlockedDecrement( &_cRef );
  377. if (0 < l)
  378. return l;
  379. delete this;
  380. return 0;
  381. }
  382. //-----------------------------------------------------------------------
  383. //
  384. // GetTypeInfoCount()
  385. //
  386. // DESCRIPTION:
  387. //
  388. // Implements the IDispatch interface method GetTypeInfoCount().
  389. //
  390. // Retrieves the number of type information interfaces that an
  391. // object provides (either 0 or 1).
  392. //
  393. // PARAMETERS:
  394. //
  395. // pctInfo [out] Points to location that receives the
  396. // number of type information interfaces
  397. // that the object provides. If the object
  398. // provides type information, this number
  399. // is set to 1; otherwise it's set to 0.
  400. //
  401. // RETURNS:
  402. //
  403. // HRESULT S_OK if the function succeeds or
  404. // E_INVALIDARG if pctInfo is invalid.
  405. //
  406. //-----------------------------------------------------------------------
  407. STDMETHODIMP CTipbarAccessible::GetTypeInfoCount( UINT *pctInfo )
  408. {
  409. if (!pctInfo)
  410. return E_INVALIDARG;
  411. *pctInfo = (_pTypeInfo == NULL ? 1 : 0);
  412. return S_OK;
  413. }
  414. //-----------------------------------------------------------------------
  415. //
  416. // GetTypeInfo()
  417. //
  418. // DESCRIPTION:
  419. //
  420. // Implements the IDispatch interface method GetTypeInfo().
  421. //
  422. // Retrieves a type information object, which can be used to
  423. // get the type information for an interface.
  424. //
  425. // PARAMETERS:
  426. //
  427. // itinfo [in] The type information to return. If this value
  428. // is 0, the type information for the IDispatch
  429. // implementation is to be retrieved.
  430. //
  431. // lcid [in] The locale ID for the type information.
  432. //
  433. // ppITypeInfo [out] Receives a pointer to the type information
  434. // object requested.
  435. //
  436. // RETURNS:
  437. //
  438. // HRESULT S_OK if the function succeeded (the TypeInfo
  439. // element exists), TYPE_E_ELEMENTNOTFOUND if
  440. // itinfo is not equal to zero, or
  441. // E_INVALIDARG if ppITypeInfo is invalid.
  442. //
  443. //-----------------------------------------------------------------------
  444. STDMETHODIMP CTipbarAccessible::GetTypeInfo( UINT itinfo, LCID lcid, ITypeInfo** ppITypeInfo )
  445. {
  446. if (!ppITypeInfo)
  447. return E_INVALIDARG;
  448. *ppITypeInfo = NULL;
  449. if (itinfo != 0)
  450. return TYPE_E_ELEMENTNOTFOUND;
  451. else if (_pTypeInfo == NULL)
  452. return E_NOTIMPL;
  453. *ppITypeInfo = _pTypeInfo;
  454. _pTypeInfo->AddRef();
  455. return S_OK;
  456. }
  457. //-----------------------------------------------------------------------
  458. //
  459. // GetIDsOfNames()
  460. //
  461. // DESCRIPTION:
  462. //
  463. // Implements the IDispatch interface method GetIDsOfNames().
  464. //
  465. // Maps a single member and an optional set of argument names
  466. // to a corresponding set of integer DISPIDs, which may be used
  467. // on subsequent calls to IDispatch::Invoke.
  468. //
  469. // PARAMETERS:
  470. //
  471. // riid [in] Reserved for future use. Must be NULL.
  472. //
  473. // rgszNames [in] Passed-in array of names to be mapped.
  474. //
  475. // cNames [in] Count of the names to be mapped.
  476. //
  477. // lcid [in] The locale context in which to interpret
  478. // the names.
  479. //
  480. // rgdispid [out] Caller-allocated array, each element of
  481. // which contains an ID corresponding to
  482. // one of the names passed in the rgszNames
  483. // array. The first element represents the
  484. // member name; the subsequent elements
  485. // represent each of the member's parameters.
  486. //
  487. // RETURNS:
  488. //
  489. // HRESULT S_OK if the function succeeded,
  490. // E_OUTOFMEMORY if there is not enough
  491. // memory to complete the call,
  492. // DISP_E_UNKNOWNNAME if one or more of
  493. // the names were not known, or
  494. // DISP_E_UNKNOWNLCID if the LCID was
  495. // not recognized.
  496. //
  497. // NOTES:
  498. //
  499. // This method simply delegates the call to
  500. // ITypeInfo::GetIDsOfNames().
  501. //-----------------------------------------------------------------------
  502. STDMETHODIMP CTipbarAccessible::GetIDsOfNames( REFIID riid, OLECHAR ** rgszNames, UINT cNames, LCID lcid, DISPID * rgdispid )
  503. {
  504. if (_pTypeInfo == NULL)
  505. return E_NOTIMPL;
  506. return _pTypeInfo->GetIDsOfNames( rgszNames, cNames, rgdispid );
  507. }
  508. //-----------------------------------------------------------------------
  509. //
  510. // Invoke()
  511. //
  512. // DESCRIPTION:
  513. //
  514. // Implements the IDispatch interface method Invoke().
  515. //
  516. // Provides access to properties and methods exposed by the
  517. // Accessible object.
  518. //
  519. // PARAMETERS:
  520. //
  521. // dispidMember [in] Identifies the dispatch member.
  522. //
  523. // riid [in] Reserved for future use. Must be NULL.
  524. //
  525. // lcid [in] The locale context in which to interpret
  526. // the names.
  527. //
  528. // wFlags [in] Flags describing the context of the
  529. // Invoke call.
  530. //
  531. // pdispparams [in,] Pointer to a structure containing an
  532. // [out] array of arguments, array of argument
  533. // dispatch IDs for named arguments, and
  534. // counts for number of elements in the
  535. // arrays.
  536. //
  537. // pvarResult [in,] Pointer to where the result is to be
  538. // [out] stored, or NULL if the caller expects
  539. // no result. This argument is ignored
  540. // if DISPATCH_PROPERTYPUT or
  541. // DISPATCH_PROPERTYPUTREF is specified.
  542. //
  543. // pexcepinfo [out] Pointer to a structure containing
  544. // exception information. This structure
  545. // should be filled in if DISP_E_EXCEPTION
  546. // is returned.
  547. //
  548. // puArgErr [out] The index within rgvarg of the first
  549. // argument that has an error. Arguments
  550. // are stored in pdispparams->rgvarg in
  551. // reverse order, so the first argument
  552. // is the one with the highest index in
  553. // the array.
  554. //
  555. // RETURNS:
  556. //
  557. // HRESULT S_OK on success, dispatch error (DISP_E_*)
  558. // or E_NOTIMPL otherwise.
  559. //
  560. // NOTES:
  561. //
  562. // This method simply delegates the call to ITypeInfo::Invoke().
  563. //-----------------------------------------------------------------------
  564. STDMETHODIMP CTipbarAccessible::Invoke( DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr )
  565. {
  566. if (_pTypeInfo == NULL)
  567. return E_NOTIMPL;
  568. return _pTypeInfo->Invoke( (IAccessible *)this,
  569. dispid,
  570. wFlags,
  571. pdispparams,
  572. pvarResult,
  573. pexcepinfo,
  574. puArgErr );
  575. }
  576. //-----------------------------------------------------------------------
  577. //
  578. // get_accParent()
  579. //
  580. // DESCRIPTION:
  581. //
  582. // Implements the IAccessible interface method get_accParent().
  583. //
  584. // Retrieves the IDispatch interface of the current object's
  585. // parent.
  586. //
  587. // PARAMETERS:
  588. //
  589. // ppdispParent [out] Pointer to the variable that will
  590. // contain a pointer to the IDispatch
  591. // interface of CTipbarAccessible's parent.
  592. //
  593. // RETURNS:
  594. //
  595. // HRESULT The value returned by the standard object's
  596. // implementation of get_accParent().
  597. //
  598. //-----------------------------------------------------------------------
  599. STDMETHODIMP CTipbarAccessible::get_accParent( IDispatch ** ppdispParent )
  600. {
  601. //
  602. // Use the default client window implementation to obtain the parent
  603. // of our Accessible object.
  604. //
  605. return _pDefAccClient->get_accParent( ppdispParent );
  606. }
  607. //-----------------------------------------------------------------------
  608. //
  609. // get_accChildCount()
  610. //
  611. // DESCRIPTION:
  612. //
  613. // Implements the IAccessible interface method get_accChildCount().
  614. //
  615. // Retrieves the number of children belonging to CTipbarAccessible.
  616. //
  617. // PARAMETERS:
  618. //
  619. // pChildCount [out] Pointer to the variable that will
  620. // be filled with the number of children
  621. // belonging to the CTipbarAccessible object.
  622. //
  623. // RETURNS:
  624. //
  625. // HRESULT S_OK on success, E_INVALIDARG if pChildCount
  626. // is invalid.
  627. //
  628. //-----------------------------------------------------------------------
  629. STDMETHODIMP CTipbarAccessible::get_accChildCount( long* pChildCount )
  630. {
  631. if (!pChildCount)
  632. return E_INVALIDARG;
  633. if (!_rgAccItems.Count())
  634. {
  635. Assert(0);
  636. return E_FAIL;
  637. }
  638. *pChildCount = (_rgAccItems.Count() - 1);
  639. return S_OK;
  640. }
  641. //-----------------------------------------------------------------------
  642. // get_accChild()
  643. //
  644. // DESCRIPTION:
  645. //
  646. // Implements the IAccessible interface method get_accChild().
  647. //
  648. // Retrieve an IDispatch interface pointer to the child object
  649. // that has the given child ID or name.
  650. //
  651. // PARAMETERS:
  652. //
  653. // varChild [in] VARIANT structure that identifies the
  654. // child to be retrieved. Since
  655. // CTipbarAccessible only supports child IDs,
  656. // the vt member of this structure must
  657. // equal VT_I4.
  658. //
  659. // ppdispChild [out] Pointer to the variable that will
  660. // contain a pointer to the IDispatch
  661. // interface of specified child object
  662. // of CTipbarAccessible.
  663. //
  664. // RETURNS:
  665. //
  666. // HRESULT E_INVALIDARG if ppdispChild is invalid, S_FALSE
  667. // otherwise because none of CTipbarAccessible's
  668. // children are objects.
  669. //
  670. //-----------------------------------------------------------------------
  671. STDMETHODIMP CTipbarAccessible::get_accChild( VARIANT varChild, IDispatch ** ppdispChild )
  672. {
  673. if (!ppdispChild)
  674. return E_INVALIDARG;
  675. //
  676. // None of the children of CTipbarAccessible are objects,
  677. // so none have IDispatch pointers. Thus, in all
  678. // cases, set the IDispatch pointer to NULL and
  679. // return S_FALSE.
  680. //
  681. *ppdispChild = NULL;
  682. return S_FALSE;
  683. }
  684. //-----------------------------------------------------------------------
  685. // get_accName()
  686. //
  687. // DESCRIPTION:
  688. //
  689. // Implements the IAccessible interface method get_accName().
  690. //
  691. // Retrieve the name property for the specified child.
  692. //
  693. // PARAMETERS:
  694. //
  695. // varChild [in] VARIANT structure that identifies the
  696. // child to be retrieved. Since
  697. // CTipbarAccessible only supports child IDs,
  698. // the vt member of this structure must
  699. // equal VT_I4.
  700. //
  701. // pszName [out] Pointer to the BSTR that will contain
  702. // the child's name property string.
  703. //
  704. // RETURNS:
  705. //
  706. // HRESULT E_INVALIDARG if either parameter is invalid
  707. // or the return value from the private method
  708. // HrLoadString().
  709. //
  710. //-----------------------------------------------------------------------
  711. STDMETHODIMP CTipbarAccessible::get_accName( VARIANT varChild, BSTR *pbstrName )
  712. {
  713. CTipbarAccItem *pAccItem;
  714. if (pbstrName == NULL) {
  715. return E_INVALIDARG;
  716. }
  717. // get acc item
  718. pAccItem = AccItemFromID( (int)varChild.lVal );
  719. if (pAccItem == NULL) {
  720. return E_INVALIDARG;
  721. }
  722. // get name of acc item
  723. *pbstrName = pAccItem->GetAccName();
  724. return (*pbstrName != NULL) ? S_OK : DISP_E_MEMBERNOTFOUND;
  725. }
  726. //-----------------------------------------------------------------------
  727. // get_accValue()
  728. //
  729. // DESCRIPTION:
  730. //
  731. // Implements the IAccessible interface method get_accValue().
  732. //
  733. // Retrieves the value property for the specified child.
  734. //
  735. // PARAMETERS:
  736. //
  737. // varChild [in] VARIANT structure that identifies the
  738. // child to be retrieved. Since
  739. // CTipbarAccessible only supports child IDs,
  740. // the vt member of this structure must
  741. // equal VT_I4.
  742. //
  743. // pszValue [out] Pointer to the BSTR that will contain
  744. // the child's value property string.
  745. //
  746. // RETURNS:
  747. //
  748. // HRESULT E_INVALIDARG if either parameter is invalid,
  749. // DISP_E_MEMBERNOTFOUND if VarChild refers
  750. // to any child other than the status bar,
  751. // or S_OK.
  752. //
  753. //-----------------------------------------------------------------------
  754. STDMETHODIMP CTipbarAccessible::get_accValue( VARIANT varChild, BSTR *pbstrValue )
  755. {
  756. CTipbarAccItem *pAccItem;
  757. if (pbstrValue == NULL)
  758. return E_INVALIDARG;
  759. // get acc item
  760. pAccItem = AccItemFromID( (int)varChild.lVal );
  761. if (pAccItem == NULL)
  762. return E_INVALIDARG;
  763. // get value of acc item
  764. *pbstrValue = pAccItem->GetAccValue();
  765. return (*pbstrValue != NULL) ? S_OK : DISP_E_MEMBERNOTFOUND;
  766. }
  767. //-----------------------------------------------------------------------
  768. // get_accDescription()
  769. //
  770. // DESCRIPTION:
  771. //
  772. // Implements the IAccessible interface method get_accDescription().
  773. //
  774. // Retrieves the description property for the specified child.
  775. //
  776. // PARAMETERS:
  777. //
  778. // varChild [in] VARIANT structure that identifies the
  779. // child to be retrieved. Since
  780. // CTipbarAccessible only supports child IDs,
  781. // the vt member of this structure must
  782. // equal VT_I4.
  783. //
  784. // pszDesc [out] Pointer to the BSTR that will contain
  785. // the child's description property string.
  786. //
  787. // RETURNS:
  788. //
  789. // HRESULT E_INVALIDARG if either parameter is invalid
  790. // or the return value from either the
  791. // standard client window implementation of
  792. // get_accDescription() or the private method
  793. // HrLoadString().
  794. //
  795. //-----------------------------------------------------------------------
  796. STDMETHODIMP CTipbarAccessible::get_accDescription( VARIANT varChild, BSTR *pbstrDesc )
  797. {
  798. if (pbstrDesc == NULL)
  799. return E_INVALIDARG;
  800. return _pDefAccClient->get_accDescription( varChild, pbstrDesc );
  801. }
  802. //-----------------------------------------------------------------------
  803. // get_accRole()
  804. //
  805. // DESCRIPTION:
  806. //
  807. // Implements the IAccessible interface method get_accRole().
  808. //
  809. // Retrieves the role property for the specified child.
  810. //
  811. // PARAMETERS:
  812. //
  813. // varChild [in] VARIANT structure that identifies the
  814. // child to be retrieved. Since
  815. // CTipbarAccessible only supports child IDs,
  816. // the vt member of this structure must
  817. // equal VT_I4.
  818. //
  819. // pVarRole [out] Pointer to the VARIANT structure that
  820. // will contain the specified child's
  821. // role property. This property may
  822. // either be in the form of a standard
  823. // role constant or a custom description
  824. // string.
  825. //
  826. // RETURNS:
  827. //
  828. // HRESULT E_INVALIDARG if either parameter is invalid,
  829. // S_OK if the specified child is the button
  830. // or status bar, or the return value from
  831. // either the standard client window implementation
  832. // of get_accRole() or the private method
  833. // HrLoadString().
  834. //
  835. //-----------------------------------------------------------------------
  836. STDMETHODIMP CTipbarAccessible::get_accRole( VARIANT varChild, VARIANT *pVarRole )
  837. {
  838. CTipbarAccItem *pAccItem;
  839. if (pVarRole == NULL)
  840. return E_INVALIDARG;
  841. // get acc item
  842. pAccItem = AccItemFromID( (int)varChild.lVal );
  843. if (pAccItem == NULL)
  844. return E_INVALIDARG;
  845. // get role of acc item
  846. pVarRole->vt = VT_I4;
  847. pVarRole->lVal = pAccItem->GetAccRole();
  848. return S_OK;
  849. }
  850. //-----------------------------------------------------------------------
  851. // get_accState()
  852. //
  853. // DESCRIPTION:
  854. //
  855. // Implements the IAccessible interface method get_accState().
  856. //
  857. // Retrieves the current state for the specified object or child.
  858. //
  859. // PARAMETERS:
  860. //
  861. // varChild [in] VARIANT structure that identifies the
  862. // child to be retrieved. Since
  863. // CTipbarAccessible only supports child IDs,
  864. // the vt member of this structure must
  865. // equal VT_I4.
  866. //
  867. // pVarState [out] Pointer to the VARIANT structure that
  868. // will contain information describing
  869. // the specified child's current state.
  870. // This information may either be in the
  871. // form of one or more object state
  872. // constants or a custom description
  873. // string.
  874. //
  875. // RETURNS:
  876. //
  877. // HRESULT E_INVALIDARG if either parameter is invalid or
  878. // S_OK.
  879. //
  880. // NOTES:
  881. //
  882. // Since the icons are HWND based objects, they can never truly
  883. // have the input focus. However, if the user clicks one, the main
  884. // window treats the icon as if it had the focus. So, the state
  885. // of the client area should not indicate "focused" when an icon
  886. // is said to have the focus.
  887. //
  888. // The push button can have the focus, but it cannot be selected.
  889. //
  890. //-----------------------------------------------------------------------
  891. STDMETHODIMP CTipbarAccessible::get_accState( VARIANT varChild, VARIANT * pVarState )
  892. {
  893. CTipbarAccItem *pAccItem;
  894. if (pVarState == NULL)
  895. return E_INVALIDARG;
  896. // get acc item
  897. pAccItem = AccItemFromID( (int)varChild.lVal );
  898. if (pAccItem == NULL)
  899. return E_INVALIDARG;
  900. // get state of acc item
  901. pVarState->vt = VT_I4;
  902. pVarState->lVal = pAccItem->GetAccState();
  903. return S_OK;
  904. }
  905. //-----------------------------------------------------------------------
  906. // get_accHelp()
  907. //
  908. // DESCRIPTION:
  909. //
  910. // Implements the IAccessible interface method get_accHelp().
  911. //
  912. // Retrieves the help property string for the specified child.
  913. //
  914. // PARAMETERS:
  915. //
  916. // varChild [in] VARIANT structure that identifies the
  917. // child to be retrieved. Since
  918. // CTipbarAccessible only supports child IDs,
  919. // the vt member of this structure must
  920. // equal VT_I4.
  921. //
  922. // pszHelp [out] Pointer to the BSTR that will contain
  923. // the child's help property string.
  924. //
  925. // RETURNS:
  926. //
  927. // HRESULT E_INVALIDARG if either parameter is invalid,
  928. // DISP_E_MEMBERNOTFOUND if VarChild refers
  929. // to any icon child, or the return value from
  930. // either the standard client window implementation
  931. // of get_accHelp() or the private method
  932. // HrLoadString().
  933. //
  934. //-----------------------------------------------------------------------
  935. STDMETHODIMP CTipbarAccessible::get_accHelp( VARIANT varChild, BSTR *pbstrHelp )
  936. {
  937. return DISP_E_MEMBERNOTFOUND; /* no support in candidate UI */
  938. }
  939. //-----------------------------------------------------------------------
  940. // get_accHelpTopic()
  941. //
  942. // DESCRIPTION:
  943. //
  944. // Implements the IAccessible interface method get_accHelpTopic().
  945. //
  946. // Retrieves the fully qualified path name of the help file
  947. // associated with the specified object, as well as a pointer
  948. // to the appropriate topic with in that file.
  949. //
  950. // PARAMETERS:
  951. //
  952. // pszHelpFile [out] Pointer to the BSTR that will contain
  953. // the fully qualified path name of the
  954. // help file associated with the child.
  955. //
  956. // varChild [in] VARIANT structure that identifies the
  957. // child to be retrieved. Since
  958. // CTipbarAccessible only supports child IDs,
  959. // the vt member of this structure must
  960. // equal VT_I4.
  961. //
  962. // pidTopic [out] Pointer to the value identifying the
  963. // help file topic associated with the
  964. // object.
  965. //
  966. // RETURNS:
  967. //
  968. // HRESULT DISP_E_MEMBERNOTFOUND because the help topic
  969. // property is not supported for the Accessible
  970. // object or any of its children.
  971. //
  972. //-----------------------------------------------------------------------
  973. STDMETHODIMP CTipbarAccessible::get_accHelpTopic( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic )
  974. {
  975. return DISP_E_MEMBERNOTFOUND; /* no support in candidate UI */
  976. }
  977. //-----------------------------------------------------------------------
  978. // get_accKeyboardShortcut()
  979. //
  980. // DESCRIPTION:
  981. //
  982. // Implements the IAccessible interface method
  983. // get_accKeyboardShortcut().
  984. //
  985. // Retrieves the specified object's keyboard shortcut property.
  986. //
  987. // PARAMETERS:
  988. //
  989. // varChild [in] VARIANT structure that identifies the
  990. // child to be retrieved. Since
  991. // CTipbarAccessible only supports child IDs,
  992. // the vt member of this structure must
  993. // equal VT_I4.
  994. //
  995. // pszShortcut [out] Pointer to the BSTR that will contain
  996. // the keyboard shortcut string, or NULL
  997. // if no keyboard shortcut is associated
  998. // with this item.
  999. //
  1000. //
  1001. // RETURNS:
  1002. //
  1003. // HRESULT DISP_E_MEMBERNOTFOUND because the keyboard
  1004. // shortcut property is not supported for the
  1005. // Accessible object or any of its children.
  1006. //
  1007. //-----------------------------------------------------------------------
  1008. STDMETHODIMP CTipbarAccessible::get_accKeyboardShortcut( VARIANT varChild, BSTR *pbstrShortcut )
  1009. {
  1010. return DISP_E_MEMBERNOTFOUND; /* no support in candidate UI */
  1011. }
  1012. //-----------------------------------------------------------------------
  1013. // get_accFocus()
  1014. //
  1015. // DESCRIPTION:
  1016. //
  1017. // Implements the IAccessible interface method get_accFocus().
  1018. //
  1019. // Retrieves the child object that currently has the input focus.
  1020. // Only one object or item within a container can have the current
  1021. // focus at any one time.
  1022. //
  1023. // PARAMETERS:
  1024. //
  1025. // pVarFocus [out] Pointer to the VARIANT structure that
  1026. // will contain information describing
  1027. // the specified child's current state.
  1028. // This information may either be in the
  1029. // form of one or more object state
  1030. // constants or a custom description
  1031. // string.
  1032. //
  1033. // RETURNS:
  1034. //
  1035. // HRESULT E_INVALIDARG if the pVarFocus parameter is
  1036. // invalid or S_OK.
  1037. //
  1038. //-----------------------------------------------------------------------
  1039. STDMETHODIMP CTipbarAccessible::get_accFocus( VARIANT *pVarFocus )
  1040. {
  1041. if (pVarFocus == NULL)
  1042. return E_INVALIDARG;
  1043. pVarFocus->vt = VT_EMPTY;
  1044. return S_FALSE;
  1045. }
  1046. //-----------------------------------------------------------------------
  1047. // get_accSelection()
  1048. //
  1049. // DESCRIPTION:
  1050. //
  1051. // Implements the IAccessible interface method get_accSelection().
  1052. //
  1053. // Retrieves the selected children of this object.
  1054. //
  1055. // PARAMETERS:
  1056. //
  1057. // pVarSel [out] Pointer to the VARIANT structure that
  1058. // will be filled with information about
  1059. // the selected child object or objects.
  1060. //
  1061. // RETURNS:
  1062. //
  1063. // HRESULT E_INVALIDARG if the pVarSel parameter is
  1064. // invalid or S_OK.
  1065. //
  1066. // NOTES:
  1067. //
  1068. // Refer to the MSAA SDK documentation for a full description
  1069. // of this method and the possible settings of pVarSel.
  1070. //
  1071. //-----------------------------------------------------------------------
  1072. STDMETHODIMP CTipbarAccessible::get_accSelection( VARIANT * pVarSel )
  1073. {
  1074. if (pVarSel == NULL)
  1075. return E_INVALIDARG;
  1076. pVarSel->vt = VT_EMPTY;
  1077. //
  1078. // check if Selected Child Id is invalid.
  1079. //
  1080. if (_rgAccItems.Count() < _lSelection)
  1081. _lSelection = 1;
  1082. if (_rgAccItems.Count() > _lSelection)
  1083. {
  1084. pVarSel->vt = VT_I4;
  1085. pVarSel->lVal = _lSelection;
  1086. }
  1087. return S_OK;
  1088. }
  1089. //-----------------------------------------------------------------------
  1090. // get_accDefaultAction()
  1091. //
  1092. // DESCRIPTION:
  1093. //
  1094. // Implements the IAccessible interface method get_accDefaultAction().
  1095. //
  1096. // Retrieves a string containing a localized, human-readable sentence
  1097. // that describes the object's default action.
  1098. //
  1099. // PARAMETERS:
  1100. //
  1101. // varChild [in] VARIANT structure that identifies the
  1102. // child whose default action string is
  1103. // to be retrieved. Since CTipbarAccessible
  1104. // only supports child IDs, the vt member
  1105. // of this structure must equal VT_I4.
  1106. //
  1107. // pszDefAct [out] Pointer to the BSTR that will contain
  1108. // the child's default action string,
  1109. // or NULL if there is no default action
  1110. // for this object.
  1111. //
  1112. // RETURNS:
  1113. //
  1114. // HRESULT E_INVALIDARG if either parameter is invalid,
  1115. // DISP_E_MEMBERNOTFOUND if VarChild refers
  1116. // to any icon child or the status bar child,
  1117. // or the return value from either the standard
  1118. // client window implementation of
  1119. // get_accDefaultAction() or the private method
  1120. // HrLoadString().
  1121. //
  1122. // NOTES:
  1123. //
  1124. // The only CTipbarAccessible child that has a default action is
  1125. // the push button.
  1126. //
  1127. //-----------------------------------------------------------------------
  1128. STDMETHODIMP CTipbarAccessible::get_accDefaultAction( VARIANT varChild, BSTR *pbstrDefAct )
  1129. {
  1130. if (pbstrDefAct == NULL)
  1131. return E_INVALIDARG;
  1132. *pbstrDefAct = NULL;
  1133. //
  1134. // check the variant.
  1135. //
  1136. if (varChild.vt != VT_I4)
  1137. return E_INVALIDARG;
  1138. CTipbarAccItem *pItem = AccItemFromID(varChild.lVal);
  1139. //
  1140. // is it a valid child id?
  1141. //
  1142. if (!pItem)
  1143. return DISP_E_MEMBERNOTFOUND; /* no support in candidate UI */
  1144. *pbstrDefAct = pItem->GetAccDefaultAction();
  1145. return *pbstrDefAct ? S_OK : S_FALSE;
  1146. }
  1147. //-----------------------------------------------------------------------
  1148. // accDoDefaultAction()
  1149. //
  1150. // DESCRIPTION:
  1151. //
  1152. // Implements the IAccessible interface method accDoDefaultAction().
  1153. //
  1154. // Performs the object's default action.
  1155. //
  1156. // PARAMETERS:
  1157. //
  1158. // varChild [in] VARIANT structure that identifies the
  1159. // child whose default action will be
  1160. // invoked. Since CTipbarAccessible only
  1161. // supports child IDs, the vt member of
  1162. // this structure must equal VT_I4.
  1163. //
  1164. // RETURNS:
  1165. //
  1166. // HRESULT E_INVALIDARG if the in-parameter is invalid,
  1167. // DISP_E_MEMBERNOTFOUND if VarChild refers
  1168. // to any icon child or the status bar child,
  1169. // S_OK if VarChild refers to the push button,
  1170. // or the return value from the standard
  1171. // client window implementation of
  1172. // accDoDefaultAction().
  1173. //
  1174. // NOTES:
  1175. //
  1176. // The only CTipbarAccessible child that has a default action is
  1177. // the push button.
  1178. //
  1179. //-----------------------------------------------------------------------
  1180. STDMETHODIMP CTipbarAccessible::accDoDefaultAction( VARIANT varChild )
  1181. {
  1182. //
  1183. // check the variant.
  1184. //
  1185. if (varChild.vt != VT_I4)
  1186. return E_INVALIDARG;
  1187. CTipbarAccItem *pItem = AccItemFromID(varChild.lVal);
  1188. //
  1189. // is it a valid child id?
  1190. //
  1191. if (!pItem)
  1192. return DISP_E_MEMBERNOTFOUND; /* no support in candidate UI */
  1193. return pItem->DoAccDefaultAction() ? S_OK : S_FALSE;
  1194. }
  1195. //-----------------------------------------------------------------------
  1196. // accSelect()
  1197. //
  1198. // DESCRIPTION:
  1199. //
  1200. // Implements the IAccessible interface method accSelect().
  1201. //
  1202. // Modifies the selection or moves the keyboard focus according
  1203. // to the specified flags.
  1204. //
  1205. // PARAMETERS:
  1206. //
  1207. // flagsSel [in] Value specifying how to change the
  1208. // the current selection. This parameter
  1209. // can be a combination of the values
  1210. // from the SELFLAG enumerated type.
  1211. //
  1212. // varChild [in] VARIANT structure that identifies the
  1213. // child to be selected. Since
  1214. // CTipbarAccessible only supports child IDs,
  1215. // the vt member of this structure must
  1216. // equal VT_I4.
  1217. //
  1218. // RETURNS:
  1219. //
  1220. // HRESULT E_INVALIDARG if either of the parameters
  1221. // is invalid, S_FALSE if the selection
  1222. // and/or focus cannot be placed at the
  1223. // requested location, or S_OK if the
  1224. // selection and/or focus can be placed
  1225. // at the requested location.
  1226. //
  1227. // NOTES:
  1228. //
  1229. // For more information on selected objects, please see the
  1230. // MSAA SDK Documentation.
  1231. //
  1232. //-----------------------------------------------------------------------
  1233. STDMETHODIMP CTipbarAccessible::accSelect( long flagsSel, VARIANT varChild )
  1234. {
  1235. //
  1236. // Validate the requested selection.
  1237. // SELFLAG_ADDSELECTION may not be combined
  1238. // with SELFLAG_REMOVESELECTION.
  1239. //
  1240. if ((flagsSel & SELFLAG_ADDSELECTION) && (flagsSel & SELFLAG_REMOVESELECTION))
  1241. return E_INVALIDARG;
  1242. //
  1243. // We don't support SetFocus.
  1244. // We don't support multi selection.
  1245. //
  1246. if ((flagsSel & SELFLAG_TAKEFOCUS) ||
  1247. (flagsSel & SELFLAG_ADDSELECTION) ||
  1248. (flagsSel & SELFLAG_EXTENDSELECTION))
  1249. return S_FALSE;
  1250. //
  1251. // do nothing on removing seleciton.
  1252. //
  1253. if (flagsSel & SELFLAG_REMOVESELECTION)
  1254. return S_OK;
  1255. //
  1256. // check the variant.
  1257. //
  1258. if (varChild.vt != VT_I4)
  1259. return E_INVALIDARG;
  1260. //
  1261. // Update selection.
  1262. //
  1263. if (flagsSel & SELFLAG_TAKESELECTION)
  1264. {
  1265. _lSelection = varChild.lVal;
  1266. return S_OK;
  1267. }
  1268. return S_FALSE;
  1269. }
  1270. //-----------------------------------------------------------------------
  1271. // accLocation()
  1272. //
  1273. // DESCRIPTION:
  1274. //
  1275. // Implements the IAccessible interface method accLocation().
  1276. //
  1277. // Retrieves the specified child's current screen location in
  1278. // screen coordinates.
  1279. //
  1280. // PARAMETERS:
  1281. //
  1282. // pxLeft [out] Address of the child's left most
  1283. // boundary.
  1284. //
  1285. // pyTop [out] Address of the child's upper most
  1286. // boundary.
  1287. //
  1288. // pcxWid [out] Address of the child's width.
  1289. //
  1290. // pcyHt [out] Address of the child's height.
  1291. //
  1292. // varChild [in] VARIANT structure that identifies the
  1293. // child whose screen location is to be
  1294. // retrieved. Since CTipbarAccessible only
  1295. // supports child IDs, the vt member
  1296. // of this structure must equal VT_I4.
  1297. //
  1298. // RETURNS:
  1299. //
  1300. // HRESULT E_INVALIDARG if any of the parameters
  1301. // are invalid, E_UNEXPECTED if we are for
  1302. // some reason unable to determine the
  1303. // window rect of the button or status bar,
  1304. // S_OK if the screen coordinates of the
  1305. // child are successfully determined, or
  1306. // the return value from the standard client
  1307. // window implementation of accLocation().
  1308. //
  1309. //-----------------------------------------------------------------------
  1310. STDMETHODIMP CTipbarAccessible::accLocation( long* pxLeft, long* pyTop, long* pcxWid, long* pcyHt, VARIANT varChild )
  1311. {
  1312. CTipbarAccItem *pAccItem;
  1313. RECT rc;
  1314. if (pxLeft == NULL || pyTop == NULL || pcxWid == NULL || pcyHt == NULL)
  1315. return E_INVALIDARG;
  1316. //
  1317. // If the child ID is CHILDID_SELF, we are being
  1318. // asked to retrieve the current screen location
  1319. // of the Accessible object itself. Delegate
  1320. // this request to the standard implementation.
  1321. //
  1322. if (varChild.lVal == CHILDID_SELF)
  1323. return _pDefAccClient->accLocation( pxLeft, pyTop, pcxWid, pcyHt, varChild );
  1324. // get acc item
  1325. pAccItem = AccItemFromID( (int)varChild.lVal );
  1326. if (pAccItem == NULL)
  1327. return E_INVALIDARG;
  1328. // get location of acc item
  1329. pAccItem->GetAccLocation( &rc );
  1330. *pxLeft = rc.left;
  1331. *pyTop = rc.top;
  1332. *pcxWid = rc.right - rc.left;
  1333. *pcyHt = rc.bottom - rc.top;
  1334. return S_OK;
  1335. }
  1336. //-----------------------------------------------------------------------
  1337. // accNavigate()
  1338. //
  1339. // DESCRIPTION:
  1340. //
  1341. // Implements the IAccessible interface method accNavigate().
  1342. //
  1343. // Retrieves the next or previous sibling or child object in a
  1344. // specified direction. This direction can be spatial order
  1345. // (such as Left and Right) or in navigational order (such as
  1346. // Next and Previous).
  1347. //
  1348. // PARAMETERS:
  1349. //
  1350. // navDir [in] A navigational constant specifying
  1351. // the direction in which to move.
  1352. //
  1353. // varStart [in] VARIANT structure that identifies the
  1354. // child from which the navigational
  1355. // change will originate. Since
  1356. // CTipbarAccessible only supports child IDs,
  1357. // the vt member of this structure must
  1358. // equal VT_I4.
  1359. //
  1360. // pVarEndUpAt [out] Pointer to the VARIANT structure that
  1361. // will contain information describing
  1362. // the destination child or object.
  1363. // If the vt member is VT_I4, then the
  1364. // lVal member is a child ID. If the
  1365. // vt member is VT_EMPTY, then the
  1366. // navigation failed.
  1367. //
  1368. // RETURNS:
  1369. //
  1370. // HRESULT E_INVALIDARG if the varStart parameter is
  1371. // invalid, or the return value from the
  1372. // default implementation of the window client
  1373. // area default Accessible object,
  1374. // DISP_E_MEMBERNOTFOUND if the combination
  1375. // of the navigation flag and the varStart
  1376. // setting is invalid, S_FALSE if the
  1377. // navigation fails, or S_OK.
  1378. //
  1379. // NOTES:
  1380. //
  1381. // Since the CTipbarAccessible object has no child objects (only child
  1382. // elements), pVarEndUpAt will never be a pointer to a IDispatch
  1383. // interface of a child object.
  1384. //
  1385. //-----------------------------------------------------------------------
  1386. STDMETHODIMP CTipbarAccessible::accNavigate( long navDir, VARIANT varStart, VARIANT* pVarEndUpAt )
  1387. {
  1388. HRESULT hr = S_FALSE;
  1389. if (_rgAccItems.Count() <= 1)
  1390. {
  1391. pVarEndUpAt->vt = VT_EMPTY;
  1392. return hr;
  1393. }
  1394. switch (navDir)
  1395. {
  1396. case NAVDIR_DOWN:
  1397. case NAVDIR_NEXT:
  1398. case NAVDIR_RIGHT:
  1399. pVarEndUpAt->vt = VT_I4;
  1400. pVarEndUpAt->lVal = varStart.lVal + 1;
  1401. if (_rgAccItems.Count() <= pVarEndUpAt->lVal)
  1402. pVarEndUpAt->lVal = 1;
  1403. hr = S_OK;
  1404. break;
  1405. case NAVDIR_UP:
  1406. case NAVDIR_PREVIOUS:
  1407. case NAVDIR_LEFT:
  1408. pVarEndUpAt->vt = VT_I4;
  1409. pVarEndUpAt->lVal = varStart.lVal - 1;
  1410. if (pVarEndUpAt->lVal <= 0)
  1411. pVarEndUpAt->lVal = (_rgAccItems.Count() - 1);
  1412. hr = S_OK;
  1413. break;
  1414. case NAVDIR_FIRSTCHILD:
  1415. pVarEndUpAt->vt = VT_I4;
  1416. pVarEndUpAt->lVal = 1;
  1417. hr = S_OK;
  1418. break;
  1419. case NAVDIR_LASTCHILD:
  1420. pVarEndUpAt->vt = VT_I4;
  1421. pVarEndUpAt->lVal = (_rgAccItems.Count() - 1);
  1422. hr = S_OK;
  1423. break;
  1424. default:
  1425. pVarEndUpAt->vt = VT_EMPTY;
  1426. break;
  1427. }
  1428. return hr; /* no support in candidate UI */
  1429. }
  1430. //-----------------------------------------------------------------------
  1431. // accHitTest()
  1432. //
  1433. // DESCRIPTION:
  1434. //
  1435. // Implements the IAccessible interface method accHitTest().
  1436. //
  1437. // Retrieves the ID of the a child at a given point on the screen.
  1438. //
  1439. // PARAMETERS:
  1440. //
  1441. // xLeft and yTop [in] The screen coordinates of the point
  1442. // to be hit tested.
  1443. //
  1444. // pVarHit [out] Pointer to the VARIANT structure that
  1445. // will contain information describing
  1446. // the hit child. If the vt member is
  1447. // VT_I4, then the lVal member is a child
  1448. // ID. If the vt member is VT_EMPTY,
  1449. // then the navigation failed.
  1450. //
  1451. // RETURNS:
  1452. //
  1453. // HRESULT E_INVALIDARG if the pVarHit parameter is
  1454. // invalid, or S_OK.
  1455. //
  1456. // NOTES:
  1457. //
  1458. // Since the CTipbarAccessible object has no child objects (only child
  1459. // elements), pVarHit will never be a pointer to a IDispatch
  1460. // interface of a child object.
  1461. //
  1462. //-----------------------------------------------------------------------
  1463. STDMETHODIMP CTipbarAccessible::accHitTest( long xLeft, long yTop, VARIANT *pVarHit )
  1464. {
  1465. int i;
  1466. POINT pt;
  1467. RECT rc;
  1468. if (!pVarHit)
  1469. return E_INVALIDARG;
  1470. // check point is inside of window
  1471. pt.x = xLeft;
  1472. pt.y = yTop;
  1473. ScreenToClient( _hWnd, &pt );
  1474. GetClientRect( _hWnd, &rc );
  1475. if (!PtInRect( &rc, pt ))
  1476. {
  1477. pVarHit->vt = VT_EMPTY;
  1478. }
  1479. else
  1480. {
  1481. pVarHit->vt = VT_I4;
  1482. pVarHit->lVal = CHILDID_SELF;
  1483. for (i = 1; i < _rgAccItems.Count(); i++)
  1484. {
  1485. CTipbarAccItem *pItem;
  1486. pItem = _rgAccItems.Get(i);
  1487. if (!pItem)
  1488. continue;
  1489. pItem->GetAccLocation( &rc );
  1490. if (PtInRect( &rc, pt ))
  1491. {
  1492. pVarHit->lVal = i;
  1493. break;
  1494. }
  1495. }
  1496. }
  1497. return S_OK;
  1498. }
  1499. //-----------------------------------------------------------------------
  1500. // put_accName()
  1501. //
  1502. // DESCRIPTION:
  1503. //
  1504. // Implements the IAccessible interface method put_accName().
  1505. //
  1506. // Sets the name property for the specified child.
  1507. //
  1508. // PARAMETERS:
  1509. //
  1510. // varChild [in] VARIANT structure that identifies the
  1511. // child whose name property is to be
  1512. // set. Since CTipbarAccessible only supports
  1513. // child IDs, the vt member of this
  1514. // structure must equal VT_I4.
  1515. //
  1516. // szName [in] String that specifies the new name for
  1517. // this child.
  1518. //
  1519. // RETURNS:
  1520. //
  1521. // HRESULT S_FALSE because the name property for any
  1522. // child may not be changed.
  1523. //
  1524. //-----------------------------------------------------------------------
  1525. STDMETHODIMP CTipbarAccessible::put_accName( VARIANT varChild, BSTR szName )
  1526. {
  1527. //
  1528. // We don't allow clients to change the name
  1529. // property of any child so we simply return
  1530. // S_FALSE.
  1531. //
  1532. return S_FALSE;
  1533. }
  1534. //-----------------------------------------------------------------------
  1535. // put_accValue()
  1536. //
  1537. // DESCRIPTION:
  1538. //
  1539. // Implements the IAccessible interface method put_accValue().
  1540. //
  1541. // Sets the value property for the specified child.
  1542. //
  1543. // PARAMETERS:
  1544. //
  1545. // varChild [in] VARIANT structure that identifies the
  1546. // child whose value property is to be
  1547. // set. Since CTipbarAccessible only supports
  1548. // child IDs, the vt member of this
  1549. // structure must equal VT_I4.
  1550. //
  1551. // szValue [in] String that specifies the new value for
  1552. // this child.
  1553. //
  1554. // RETURNS:
  1555. //
  1556. // HRESULT S_FALSE because the value property for any
  1557. // child may not be changed.
  1558. //
  1559. //-----------------------------------------------------------------------
  1560. STDMETHODIMP CTipbarAccessible::put_accValue( VARIANT varChild, BSTR szValue )
  1561. {
  1562. //
  1563. // We don't allow clients to change the value
  1564. // property of the status bar (the only child that
  1565. // has a value property) so we simply return S_FALSE.
  1566. //
  1567. return S_FALSE;
  1568. }
  1569. //----------------------------------------------------------------------------
  1570. //
  1571. // AccItemFromID
  1572. //
  1573. //----------------------------------------------------------------------------
  1574. CTipbarAccItem *CTipbarAccessible::AccItemFromID( int iID )
  1575. {
  1576. if ((iID < 0) || (_rgAccItems.Count() <= iID))
  1577. return NULL;
  1578. return _rgAccItems.Get(iID);
  1579. }
  1580. //----------------------------------------------------------------------------
  1581. //
  1582. // ClearAccItems
  1583. //
  1584. //----------------------------------------------------------------------------
  1585. void CTipbarAccessible::ClearAccItems( void )
  1586. {
  1587. _rgAccItems.Clear();
  1588. }
  1589. //----------------------------------------------------------------------------
  1590. //
  1591. // AddAccItem
  1592. //
  1593. //----------------------------------------------------------------------------
  1594. BOOL CTipbarAccessible::AddAccItem( CTipbarAccItem *pAccItem )
  1595. {
  1596. CTipbarAccItem **ppItem;
  1597. ppItem = _rgAccItems.Append(1);
  1598. if (!ppItem)
  1599. return FALSE;
  1600. *ppItem = pAccItem;
  1601. return TRUE;
  1602. }
  1603. //----------------------------------------------------------------------------
  1604. //
  1605. // RemoveAccItem
  1606. //
  1607. //----------------------------------------------------------------------------
  1608. BOOL CTipbarAccessible::RemoveAccItem( CTipbarAccItem *pAccItem )
  1609. {
  1610. int i;
  1611. for (i = 0; i < _rgAccItems.Count(); i++)
  1612. {
  1613. CTipbarAccItem *pItem;
  1614. pItem = _rgAccItems.Get(i);
  1615. if (pItem == pAccItem)
  1616. {
  1617. _rgAccItems.Remove(i, 1);
  1618. }
  1619. }
  1620. return NULL;
  1621. }
  1622. //----------------------------------------------------------------------------
  1623. //
  1624. // DoDefaultActionReal
  1625. //
  1626. //----------------------------------------------------------------------------
  1627. BOOL CTipbarAccessible::DoDefaultActionReal(int nId)
  1628. {
  1629. CTipbarAccItem *pItem = AccItemFromID(nId);
  1630. //
  1631. // is it a valid child id?
  1632. //
  1633. if (!pItem)
  1634. return FALSE;
  1635. return pItem->DoAccDefaultActionReal();
  1636. }
  1637. //----------------------------------------------------------------------------
  1638. //
  1639. // GetIDOfItem
  1640. //
  1641. //----------------------------------------------------------------------------
  1642. int CTipbarAccessible::GetIDOfItem( CTipbarAccItem *pAccItem )
  1643. {
  1644. int i;
  1645. for (i = 0; i < _rgAccItems.Count(); i++)
  1646. {
  1647. CTipbarAccItem *pItem;
  1648. pItem = _rgAccItems.Get(i);
  1649. if (pItem == pAccItem)
  1650. {
  1651. return i;
  1652. }
  1653. }
  1654. return -1;
  1655. }
  1656. //----------------------------------------------------------------------------
  1657. //
  1658. // NotifyWinEvent
  1659. //
  1660. //----------------------------------------------------------------------------
  1661. void CTipbarAccessible::NotifyWinEvent( DWORD dwEvent, CTipbarAccItem *pAccItem )
  1662. {
  1663. Assert( pAccItem != NULL );
  1664. int nId = GetIDOfItem(pAccItem);
  1665. if (nId < 0)
  1666. {
  1667. // Assert(0);
  1668. return;
  1669. }
  1670. OurNotifyWinEvent( dwEvent, _hWnd, OBJID_CLIENT, nId);
  1671. }
  1672. //----------------------------------------------------------------------------
  1673. //
  1674. // CreateRefToAccObj
  1675. //
  1676. //----------------------------------------------------------------------------
  1677. LRESULT CTipbarAccessible::CreateRefToAccObj( WPARAM wParam )
  1678. {
  1679. return LresultFromObject( IID_IAccessible, wParam, (IAccessible *)this );
  1680. }