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.

1160 lines
34 KiB

  1. //=======================================================================
  2. // File: ACCPLV.CPP
  3. //=======================================================================
  4. #ifndef WIN32_LEAN_AND_MEAN
  5. #define WIN32_LEAN_AND_MEAN
  6. #endif
  7. #include <windows.h>
  8. #include <windowsx.h>
  9. #include <commctrl.h>
  10. #include "winapi.h"
  11. #include <ole2.h>
  12. //#include <initguid.h>
  13. // 98/07/28 kwada
  14. // Some ids are defined in oleacc.h
  15. // Instances of them are in oleacc.dll.
  16. // Initguid is needed because oleacc.lib is not linked.
  17. // To avoid conflict of instanciation of those guid,
  18. // initguid appears only once in the application.
  19. //#include "../msaa/inc32/oleacc.h"
  20. //#include "../msaa/inc32/winable.h"
  21. //980112 ToshiaK: VC6 has these include files.
  22. #include <oleacc.h>
  23. #include <winable.h>
  24. #include "accplv.h"
  25. #include "plv.h"
  26. #include "plv_.h"
  27. #include "plvproc.h"
  28. #include "dbg.h"
  29. #include "strutil.h"
  30. //#include "repview.h"
  31. //#include "iconview.h"
  32. #include "rvmisc.h"
  33. #include "ivmisc.h"
  34. CAccPLV::CAccPLV()
  35. {
  36. m_hWnd = NULL;
  37. m_pTypeInfo = NULL;
  38. m_pDefAccessible = NULL;
  39. }
  40. CAccPLV::~CAccPLV( void )
  41. {
  42. if ( m_pTypeInfo )
  43. {
  44. m_pTypeInfo->Release();
  45. m_pTypeInfo = NULL;
  46. }
  47. if ( m_pDefAccessible )
  48. {
  49. m_pDefAccessible->Release();
  50. m_pDefAccessible = NULL;
  51. }
  52. }
  53. void *
  54. CAccPLV::operator new(size_t size){
  55. return MemAlloc(size);
  56. }
  57. void
  58. CAccPLV::operator delete(void *ptr){
  59. if(ptr)
  60. MemFree(ptr);
  61. }
  62. HRESULT CAccPLV::Initialize(HWND hWnd)
  63. {
  64. HRESULT hr;
  65. ITypeLib * piTypeLib;
  66. m_hWnd = hWnd;
  67. m_lpPlv = GetPlvDataFromHWND(hWnd);
  68. if(!PLV_IsMSAAAvailable(m_lpPlv))
  69. return E_FAIL;
  70. hr = PLV_CreateStdAccessibleObject(m_lpPlv,
  71. hWnd,
  72. OBJID_CLIENT,
  73. IID_IAccessible,
  74. (void **) &m_pDefAccessible);
  75. if (FAILED( hr ))
  76. return hr;
  77. //-----------------------------------------------------
  78. // Obtain an ITypeInfo pointer to our type library.
  79. // The ITypeInfo pointer is used to implement the
  80. // IDispatch interface.
  81. //-----------------------------------------------------
  82. //-----------------------------------------------------
  83. // First, attempt to load the Accessibility type
  84. // library version 1.0 using the registry.
  85. //-----------------------------------------------------
  86. hr = LoadRegTypeLib( LIBID_Accessibility, 1, 0, 0, &piTypeLib );
  87. //-----------------------------------------------------
  88. // If we fail to load the type library from the
  89. // registry information, explicitly try to load
  90. // it from the MSAA system DLL.
  91. //-----------------------------------------------------
  92. if ( FAILED( hr ) )
  93. {
  94. static OLECHAR szOleAcc[] = L"OLEACC.DLL";
  95. hr = LoadTypeLib( szOleAcc, &piTypeLib );
  96. }
  97. //-----------------------------------------------------
  98. // If we successfully load the type library, attempt
  99. // to get the IAccessible type description
  100. // (ITypeInfo pointer) from the type library.
  101. //-----------------------------------------------------
  102. if ( SUCCEEDED( hr ) )
  103. {
  104. hr = piTypeLib->GetTypeInfoOfGuid( IID_IAccessible, &m_pTypeInfo );
  105. piTypeLib->Release();
  106. }
  107. return hr;
  108. }
  109. //-----------------------------------------------------------------------
  110. // CAccPLV::QueryInterface()
  111. // ----------------------------------------------------------------------
  112. STDMETHODIMP CAccPLV::QueryInterface( REFIID riid, void** ppv )
  113. {
  114. *ppv = NULL;
  115. //-----------------------------------------------------
  116. // If the IUnknown, IDispatch, or IAccessible
  117. // interface is desired, simply cast the this
  118. // pointer appropriately.
  119. //-----------------------------------------------------
  120. if ( riid == IID_IUnknown )
  121. *ppv = (LPUNKNOWN) this;
  122. else if ( riid == IID_IDispatch )
  123. *ppv = (IDispatch *) this;
  124. else if ( riid == IID_IAccessible )
  125. *ppv = (IAccessible *)this;
  126. //-----------------------------------------------------
  127. // If the IEnumVARIANT interface is desired, create
  128. // a new VARIANT enumerator which contains all
  129. // the Accessible object's children.
  130. //-----------------------------------------------------
  131. #ifdef NOTIMPLEMENTED
  132. else if (riid == IID_IEnumVARIANT)
  133. {
  134. return m_pDefAccessible->QueryInterface(riid, ppv);
  135. //?? AddRef();
  136. }
  137. #endif
  138. //-----------------------------------------------------
  139. // If the desired interface isn't one we know about,
  140. // return E_NOINTERFACE.
  141. //-----------------------------------------------------
  142. else
  143. return E_NOINTERFACE;
  144. //-----------------------------------------------------
  145. // Increase the reference count of any interface
  146. // returned.
  147. //-----------------------------------------------------
  148. ((LPUNKNOWN) *ppv)->AddRef();
  149. return S_OK;
  150. }
  151. //-----------------------------------------------------------------------
  152. // CAccPLV::AddRef()
  153. // CAccPLV::Release()
  154. // NOTES:
  155. //
  156. // The lifetime of the Accessible object is governed by the
  157. // lifetime of the HWND object for which it provides
  158. // Accessibility. The object is created in response to the
  159. // first WM_GETOBJECT message that the server application
  160. // is ready to process and is destroyed when the server's
  161. // main window is destroyed. Since the object's lifetime
  162. // is not dependent on a reference count, the object has no
  163. // internal mechanism for tracking reference counting and
  164. // AddRef() and Release() always return one.
  165. //
  166. //-----------------------------------------------------------------------
  167. STDMETHODIMP_(ULONG) CAccPLV::AddRef( void )
  168. {
  169. return 1L;
  170. }
  171. STDMETHODIMP_(ULONG) CAccPLV::Release( void )
  172. {
  173. return 1L;
  174. }
  175. //-----------------------------------------------------------------------
  176. // CAccPLV::GetTypeInfoCount()
  177. //
  178. // DESCRIPTION:
  179. //
  180. // Implements the IDispatch interface method GetTypeInfoCount().
  181. //
  182. // Retrieves the number of type information interfaces that an
  183. // object provides (either 0 or 1).
  184. //
  185. // PARAMETERS:
  186. //
  187. // pctInfo [out] Points to location that receives the
  188. // number of type information interfaces
  189. // that the object provides. If the object
  190. // provides type information, this number
  191. // is set to 1; otherwise it's set to 0.
  192. //
  193. // RETURNS:
  194. //
  195. // HRESULT S_OK if the function succeeds or
  196. // E_INVALIDARG if pctInfo is invalid.
  197. //
  198. //-----------------------------------------------------------------------
  199. STDMETHODIMP CAccPLV::GetTypeInfoCount( UINT *pctInfo )
  200. {
  201. if ( !pctInfo )
  202. return E_INVALIDARG;
  203. *pctInfo = ( m_pTypeInfo == NULL ? 1 : 0 );
  204. return S_OK;
  205. }
  206. //-----------------------------------------------------------------------
  207. // CAccPLV:GetTypeInfo()
  208. //
  209. // DESCRIPTION:
  210. //
  211. // Implements the IDispatch interface method GetTypeInfo().
  212. //
  213. // Retrieves a type information object, which can be used to
  214. // get the type information for an interface.
  215. //
  216. // PARAMETERS:
  217. //
  218. // itinfo [in] The type information to return. If this value
  219. // is 0, the type information for the IDispatch
  220. // implementation is to be retrieved.
  221. //
  222. // lcid [in] The locale ID for the type information.
  223. //
  224. // ppITypeInfo [out] Receives a pointer to the type information
  225. // object requested.
  226. //
  227. // RETURNS:
  228. //
  229. // HRESULT S_OK if the function succeeded (the TypeInfo
  230. // element exists), TYPE_E_ELEMENTNOTFOUND if
  231. // itinfo is not equal to zero, or
  232. // E_INVALIDARG if ppITypeInfo is invalid.
  233. //
  234. //-----------------------------------------------------------------------
  235. STDMETHODIMP CAccPLV::GetTypeInfo( UINT itinfo, LCID lcid, ITypeInfo** ppITypeInfo )
  236. {
  237. if ( !ppITypeInfo )
  238. return E_INVALIDARG;
  239. *ppITypeInfo = NULL;
  240. if ( itinfo != 0 )
  241. return TYPE_E_ELEMENTNOTFOUND;
  242. else if ( m_pTypeInfo == NULL )
  243. return E_NOTIMPL;
  244. *ppITypeInfo = m_pTypeInfo;
  245. m_pTypeInfo->AddRef();
  246. return S_OK;
  247. UNREFERENCED_PARAMETER(lcid);
  248. }
  249. //-----------------------------------------------------------------------
  250. // CAccPLV::GetIDsOfNames()
  251. //
  252. // DESCRIPTION:
  253. //
  254. // Implements the IDispatch interface method GetIDsOfNames().
  255. //
  256. // Maps a single member and an optional set of argument names
  257. // to a corresponding set of integer DISPIDs, which may be used
  258. // on subsequent calls to IDispatch::Invoke.
  259. //
  260. // NOTES:
  261. //
  262. // This method simply delegates the call to
  263. // ITypeInfo::GetIDsOfNames().
  264. //-----------------------------------------------------------------------
  265. STDMETHODIMP CAccPLV::GetIDsOfNames( REFIID riid, OLECHAR ** rgszNames, UINT cNames,
  266. LCID lcid, DISPID * rgdispid )
  267. {
  268. if ( m_pTypeInfo == NULL )
  269. return E_NOTIMPL;
  270. return( m_pTypeInfo->GetIDsOfNames( rgszNames, cNames, rgdispid ) );
  271. UNREFERENCED_PARAMETER(riid);
  272. UNREFERENCED_PARAMETER(lcid);
  273. }
  274. //-----------------------------------------------------------------------
  275. // CAccPLV::Invoke()
  276. //-----------------------------------------------------------------------
  277. STDMETHODIMP CAccPLV::Invoke( DISPID dispid,
  278. REFIID riid,
  279. LCID lcid,
  280. WORD wFlags,
  281. DISPPARAMS * pdispparams,
  282. VARIANT *pvarResult,
  283. EXCEPINFO *pexcepinfo,
  284. UINT *puArgErr )
  285. {
  286. if ( m_pTypeInfo == NULL )
  287. return E_NOTIMPL;
  288. return m_pTypeInfo->Invoke( (IAccessible *)this,
  289. dispid,
  290. wFlags,
  291. pdispparams,
  292. pvarResult,
  293. pexcepinfo,
  294. puArgErr );
  295. UNREFERENCED_PARAMETER(riid);
  296. UNREFERENCED_PARAMETER(lcid);
  297. }
  298. //-----------------------------------------------------------------------
  299. // CAccPLV::get_accParent()
  300. //-----------------------------------------------------------------------
  301. STDMETHODIMP CAccPLV::get_accParent( IDispatch ** ppdispParent )
  302. {
  303. return m_pDefAccessible->get_accParent( ppdispParent );
  304. }
  305. //-----------------------------------------------------------------------
  306. // CAccPLV::get_accChildCount()
  307. //-----------------------------------------------------------------------
  308. STDMETHODIMP CAccPLV::get_accChildCount( long* pChildCount )
  309. {
  310. if(!PLV_IsMSAAAvailable(m_lpPlv))
  311. return E_FAIL;
  312. if ( !pChildCount )
  313. return E_INVALIDARG;
  314. if(m_lpPlv->dwStyle == PLVSTYLE_ICON) // iconview
  315. *pChildCount = m_lpPlv->iItemCount;
  316. else
  317. *pChildCount = (m_lpPlv->iItemCount + 1) * RV_GetColumn(m_lpPlv); // include header
  318. return S_OK;
  319. }
  320. //-----------------------------------------------------------------------
  321. // CAccPLV::get_accChild()
  322. //-----------------------------------------------------------------------
  323. STDMETHODIMP CAccPLV::get_accChild( VARIANT varChild, IDispatch ** ppdispChild )
  324. {
  325. if ( !ppdispChild )
  326. return E_INVALIDARG;
  327. *ppdispChild = NULL;
  328. return S_FALSE;
  329. UNREFERENCED_PARAMETER(varChild);
  330. }
  331. //-----------------------------------------------------------------------
  332. // CAccPLV::get_accName()
  333. //
  334. // DESCRIPTION:
  335. //
  336. // Implements the IAccessible interface method get_accName().
  337. //
  338. // Retrieve the name property for the specified child.
  339. //
  340. // PARAMETERS:
  341. //
  342. // varChild [in] VARIANT structure that identifies the
  343. // child to be retrieved. Since
  344. // CAccPLV only supports child IDs,
  345. // the vt member of this structure must
  346. // equal VT_I4.
  347. //
  348. // pszName [out] Pointer to the BSTR that will contain
  349. // the child's name property string.
  350. //-----------------------------------------------------------------------
  351. #define BUFLEN 128
  352. STDMETHODIMP CAccPLV::get_accName( VARIANT varChild, BSTR* pszName )
  353. {
  354. if (!pszName)
  355. return E_INVALIDARG;
  356. *pszName = NULL;
  357. if ( varChild.lVal == CHILDID_SELF )
  358. //return m_pDefAccessible->get_accName(varChild,pszName);
  359. return S_OK;
  360. if(m_lpPlv->dwStyle == PLVSTYLE_ICON) {
  361. PLVITEM plvItem;
  362. m_lpPlv->lpfnPlvIconItemCallback(m_lpPlv->iconItemCallbacklParam,
  363. varChild.lVal - 1,
  364. &plvItem);
  365. *pszName = SysAllocString(plvItem.lpwstr);
  366. }
  367. else {
  368. static TCHAR szString[BUFLEN];
  369. static OLECHAR wszString[BUFLEN];
  370. static INT nCol,index,colIndex;
  371. nCol = RV_GetColumn(m_lpPlv);
  372. if (nCol < 1)
  373. return E_FAIL;
  374. index = (varChild.lVal - 1) / nCol;
  375. colIndex = (varChild.lVal - 1) % nCol;
  376. if(!index) { // Header
  377. if(IsWindowUnicode(m_lpPlv->hwndHeader)){
  378. static HD_ITEMW hdItem;
  379. hdItem.mask = HDI_TEXT;
  380. hdItem.fmt = HDF_STRING;
  381. hdItem.pszText = wszString;
  382. hdItem.cchTextMax = BUFLEN;
  383. SendMessageW(m_lpPlv->hwndHeader, HDM_GETITEMW, (WPARAM)colIndex, (LPARAM)&hdItem);
  384. *pszName = SysAllocString(hdItem.pszText);
  385. }
  386. else{
  387. static HD_ITEMA hdItem;
  388. hdItem.mask = HDI_TEXT;
  389. hdItem.fmt = HDF_STRING;
  390. hdItem.pszText = szString;
  391. hdItem.cchTextMax = BUFLEN;
  392. SendMessageA(m_lpPlv->hwndHeader, HDM_GETITEMA, (WPARAM)colIndex, (LPARAM)&hdItem);
  393. MultiByteToWideChar(m_lpPlv->codePage,MB_PRECOMPOSED,hdItem.pszText,-1,
  394. wszString,hdItem.cchTextMax);
  395. *pszName = SysAllocString(wszString);
  396. }
  397. }
  398. else { // item
  399. LPPLVITEM lpPlvItemList = (LPPLVITEM)MemAlloc(sizeof(PLVITEM)*nCol);
  400. if(!lpPlvItemList)
  401. return E_FAIL;
  402. ZeroMemory(lpPlvItemList, sizeof(PLVITEM)*nCol);
  403. m_lpPlv->lpfnPlvRepItemCallback(m_lpPlv->repItemCallbacklParam,
  404. index-1, // line index
  405. nCol, //column Count.
  406. lpPlvItemList);
  407. *pszName = SysAllocString(lpPlvItemList[colIndex].lpwstr);
  408. MemFree(lpPlvItemList);
  409. }
  410. }
  411. return S_OK;
  412. }
  413. //-----------------------------------------------------------------------
  414. // CAccPLV::get_accValue()
  415. //
  416. // DESCRIPTION:
  417. //
  418. // Implements the IAccessible interface method get_accValue().
  419. //
  420. // Retrieves the value property for the specified child.
  421. //-----------------------------------------------------------------------
  422. STDMETHODIMP CAccPLV::get_accValue( VARIANT varChild, BSTR* pszValue )
  423. {
  424. if (!pszValue)
  425. return E_INVALIDARG;
  426. return m_pDefAccessible->get_accValue(varChild,pszValue);
  427. }
  428. //-----------------------------------------------------------------------
  429. // CAccPLV::get_accDescription()
  430. //
  431. // DESCRIPTION:
  432. //
  433. // Implements the IAccessible interface method get_accDescription().
  434. //
  435. // Retrieves the description property for the specified child.
  436. //
  437. //-----------------------------------------------------------------------
  438. STDMETHODIMP CAccPLV::get_accDescription( VARIANT varChild, BSTR* pszDesc )
  439. {
  440. if (!pszDesc)
  441. return E_INVALIDARG;
  442. return m_pDefAccessible->get_accDescription(varChild,pszDesc);
  443. }
  444. //-----------------------------------------------------------------------
  445. // CAccPLV::get_accRole()
  446. //
  447. // DESCRIPTION:
  448. //
  449. // Implements the IAccessible interface method get_accRole().
  450. //
  451. // Retrieves the role property for the specified child.
  452. //
  453. // PARAMETERS:
  454. //
  455. // varChild [in] VARIANT structure that identifies the
  456. // child to be retrieved. Since
  457. // CAccPLV only supports child IDs,
  458. // the vt member of this structure must
  459. // equal VT_I4.
  460. //
  461. // pVarRole [out] Pointer to the VARIANT structure that
  462. // will contain the specified child's
  463. // role property. This property may
  464. // either be in the form of a standard
  465. // role constant or a custom description
  466. // string.
  467. //-----------------------------------------------------------------------
  468. STDMETHODIMP CAccPLV::get_accRole( VARIANT varChild, VARIANT * pVarRole )
  469. {
  470. if (!pVarRole)
  471. return E_INVALIDARG;
  472. if ( varChild.lVal == CHILDID_SELF )
  473. return m_pDefAccessible->get_accRole( varChild, pVarRole );
  474. pVarRole->vt = VT_I4;
  475. pVarRole->lVal = ROLE_SYSTEM_CLIENT;
  476. return S_OK;
  477. }
  478. //-----------------------------------------------------------------------
  479. // CAccPLV::get_accState()
  480. //
  481. // DESCRIPTION:
  482. //
  483. // Implements the IAccessible interface method get_accState().
  484. // Retrieves the current state for the specified object or child.
  485. //
  486. // PARAMETERS:
  487. //
  488. // varChild [in] VARIANT structure that identifies the
  489. // child to be retrieved. Since
  490. // CAccPLV only supports child IDs,
  491. // the vt member of this structure must
  492. // equal VT_I4.
  493. //
  494. // pVarState [out] Pointer to the VARIANT structure that
  495. // will contain information describing
  496. // the specified child's current state.
  497. // This information may either be in the
  498. // form of one or more object state
  499. // constants or a custom description
  500. // string.
  501. //-----------------------------------------------------------------------
  502. STDMETHODIMP CAccPLV::get_accState( VARIANT varChild, VARIANT * pVarState )
  503. {
  504. if(!PLV_IsMSAAAvailable(m_lpPlv))
  505. return E_FAIL;
  506. if (!pVarState)
  507. return E_INVALIDARG;
  508. if ( varChild.lVal == CHILDID_SELF )
  509. return m_pDefAccessible->get_accState(varChild,pVarState);
  510. pVarState->vt = VT_I4;
  511. if(m_lpPlv->dwStyle == PLVSTYLE_ICON) // iconview
  512. pVarState->lVal = STATE_SYSTEM_SELECTABLE;
  513. else { // report view
  514. static INT nCol,index,colIndex;
  515. nCol = RV_GetColumn(m_lpPlv);
  516. if (nCol < 1)
  517. return E_FAIL;
  518. index = (varChild.lVal - 1) / nCol;
  519. colIndex = (varChild.lVal - 1) % nCol;
  520. if(index){
  521. if(colIndex)
  522. pVarState->lVal = STATE_SYSTEM_READONLY;
  523. else // item
  524. pVarState->lVal = STATE_SYSTEM_SELECTABLE;
  525. }
  526. else{ // header
  527. pVarState->lVal = STATE_SYSTEM_READONLY;
  528. }
  529. }
  530. return S_OK;
  531. UNREFERENCED_PARAMETER(varChild);
  532. }
  533. //-----------------------------------------------------------------------
  534. // CAccPLV::get_accHelp()
  535. //
  536. // DESCRIPTION:
  537. //
  538. // Implements the IAccessible interface method get_accHelp().
  539. //
  540. // Retrieves the help property string for the specified child.
  541. //
  542. // PARAMETERS:
  543. //
  544. // varChild [in] VARIANT structure that identifies the
  545. // child to be retrieved. Since
  546. // CAccPLV only supports child IDs,
  547. // the vt member of this structure must
  548. // equal VT_I4.
  549. //
  550. // pszHelp [out] Pointer to the BSTR that will contain
  551. // the child's help property string.
  552. //
  553. //-----------------------------------------------------------------------
  554. STDMETHODIMP CAccPLV::get_accHelp( VARIANT varChild, BSTR* pszHelp )
  555. {
  556. if (!pszHelp)
  557. return E_INVALIDARG;
  558. return m_pDefAccessible->get_accHelp( varChild, pszHelp );
  559. }
  560. //-----------------------------------------------------------------------
  561. // CAccPLV::get_accHelpTopic()
  562. //
  563. // DESCRIPTION:
  564. //
  565. // Implements the IAccessible interface method get_accHelpTopic().
  566. //
  567. // Retrieves the fully qualified path name of the help file
  568. // associated with the specified object, as well as a pointer
  569. // to the appropriate topic with in that file.
  570. //
  571. // PARAMETERS:
  572. //
  573. // pszHelpFile [out] Pointer to the BSTR that will contain
  574. // the fully qualified path name of the
  575. // help file associated with the child.
  576. //
  577. // varChild [in] VARIANT structure that identifies the
  578. // child to be retrieved. Since
  579. // CAccPLV only supports child IDs,
  580. // the vt member of this structure must
  581. // equal VT_I4.
  582. //
  583. // pidTopic [out] Pointer to the value identifying the
  584. // help file topic associated with the
  585. // object.
  586. //
  587. // RETURNS:
  588. //
  589. // HRESULT DISP_E_MEMBERNOTFOUND because the help topic
  590. // property is not supported for the Accessible
  591. // object or any of its children.
  592. //
  593. //-----------------------------------------------------------------------
  594. STDMETHODIMP CAccPLV::get_accHelpTopic( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic )
  595. {
  596. //-----------------------------------------------------
  597. // The help topic property is not supported for
  598. // either the Accessible object or any of its
  599. // children.
  600. //-----------------------------------------------------
  601. //return m_pDefAccessible->get_accHelpTopic(pszHelpFile,varChild,pidTopic);
  602. return DISP_E_MEMBERNOTFOUND;
  603. UNREFERENCED_PARAMETER(pszHelpFile);
  604. UNREFERENCED_PARAMETER(varChild);
  605. UNREFERENCED_PARAMETER(pidTopic);
  606. }
  607. //-----------------------------------------------------------------------
  608. // CAccPLV::get_accKeyboardShortcut()
  609. //
  610. // DESCRIPTION:
  611. //
  612. // Implements the IAccessible interface method
  613. // get_accKeyboardShortcut().
  614. //
  615. // Retrieves the specified object's keyboard shortcut property.
  616. //
  617. // PARAMETERS:
  618. //
  619. // varChild [in] VARIANT structure that identifies the
  620. // child to be retrieved. Since
  621. // CAccPLV only supports child IDs,
  622. // the vt member of this structure must
  623. // equal VT_I4.
  624. //
  625. // pszShortcut [out] Pointer to the BSTR that will contain
  626. // the keyboard shortcut string, or NULL
  627. // if no keyboard shortcut is associated
  628. // with this item.
  629. //
  630. //
  631. // RETURNS:
  632. //
  633. // HRESULT DISP_E_MEMBERNOTFOUND because the keyboard
  634. // shortcut property is not supported for the
  635. // Accessible object or any of its children.
  636. //
  637. //-----------------------------------------------------------------------
  638. STDMETHODIMP CAccPLV::get_accKeyboardShortcut( VARIANT varChild, BSTR* pszShortcut )
  639. {
  640. //-----------------------------------------------------
  641. // The keyboard shortcut property is not supported
  642. // for either the Accessible object or any of its
  643. // children. So, set pszShortcut to NULL and
  644. // return DISP_E_MEMBERNOTFOUND.
  645. //-----------------------------------------------------
  646. if(!pszShortcut)
  647. return E_INVALIDARG;
  648. return m_pDefAccessible->get_accKeyboardShortcut(varChild,pszShortcut);
  649. #ifdef REF
  650. pszShortcut = NULL;
  651. return DISP_E_MEMBERNOTFOUND;
  652. #endif
  653. }
  654. //-----------------------------------------------------------------------
  655. // CAccPLV::get_accFocus()
  656. //
  657. // DESCRIPTION:
  658. //
  659. // Implements the IAccessible interface method get_accFocus().
  660. //
  661. // Retrieves the child object that currently has the input focus.
  662. // Only one object or item within a container can have the current
  663. // focus at any one time.
  664. //
  665. // PARAMETERS:
  666. //
  667. // pVarFocus [out] Pointer to the VARIANT structure that
  668. // will contain information describing
  669. // the specified child's current state.
  670. // This information may either be in the
  671. // form of one or more object state
  672. // constants or a custom description
  673. // string.
  674. //
  675. // RETURNS:
  676. //
  677. // HRESULT E_INVALIDARG if the pVarFocus parameter is
  678. // invalid or S_OK.
  679. //
  680. //-----------------------------------------------------------------------
  681. STDMETHODIMP CAccPLV::get_accFocus( VARIANT * pVarFocus )
  682. {
  683. if ( !pVarFocus )
  684. return E_INVALIDARG;
  685. return m_pDefAccessible->get_accFocus(pVarFocus);
  686. }
  687. //-----------------------------------------------------------------------
  688. // CAccPLV::get_accSelection()
  689. //
  690. // DESCRIPTION:
  691. //
  692. // Implements the IAccessible interface method get_accSelection().
  693. //
  694. // Retrieves the selected children of this object.
  695. //
  696. // PARAMETERS:
  697. //
  698. // pVarSel [out] Pointer to the VARIANT structure that
  699. // will be filled with information about
  700. // the selected child object or objects.
  701. //
  702. // RETURNS:
  703. //
  704. // HRESULT E_INVALIDARG if the pVarSel parameter is
  705. // invalid or S_OK.
  706. //
  707. // NOTES:
  708. //
  709. // Refer to the MSAA SDK documentation for a full description
  710. // of this method and the possible settings of pVarSel.
  711. //
  712. //-----------------------------------------------------------------------
  713. STDMETHODIMP CAccPLV::get_accSelection( VARIANT * pVarSel )
  714. {
  715. if ( !pVarSel )
  716. return E_INVALIDARG;
  717. return m_pDefAccessible->get_accSelection(pVarSel);
  718. }
  719. //-----------------------------------------------------------------------
  720. // CAccPLV::get_accDefaultAction()
  721. //
  722. // DESCRIPTION:
  723. //
  724. // Implements the IAccessible interface method get_accDefaultAction().
  725. //
  726. // Retrieves a string containing a localized, human-readable sentence
  727. // that describes the object's default action.
  728. //
  729. // PARAMETERS:
  730. //
  731. // varChild [in] VARIANT structure that identifies the
  732. // child whose default action string is
  733. // to be retrieved. Since CAccPLV
  734. // only supports child IDs, the vt member
  735. // of this structure must equal VT_I4.
  736. //
  737. // pszDefAct [out] Pointer to the BSTR that will contain
  738. // the child's default action string,
  739. // or NULL if there is no default action
  740. // for this object.
  741. //-----------------------------------------------------------------------
  742. STDMETHODIMP CAccPLV::get_accDefaultAction( VARIANT varChild, BSTR* pszDefAct )
  743. {
  744. if (!pszDefAct)
  745. return E_INVALIDARG;
  746. return m_pDefAccessible->get_accDefaultAction(varChild, pszDefAct);
  747. }
  748. //-----------------------------------------------------------------------
  749. // CAccPLV::accDoDefaultAction()
  750. //
  751. // DESCRIPTION:
  752. //
  753. // Implements the IAccessible interface method accDoDefaultAction().
  754. //
  755. // Performs the object's default action.
  756. //
  757. // PARAMETERS:
  758. //
  759. // varChild [in] VARIANT structure that identifies the
  760. // child whose default action will be
  761. // invoked. Since CAccPLV only
  762. // supports child IDs, the vt member of
  763. // this structure must equal VT_I4.
  764. //-----------------------------------------------------------------------
  765. STDMETHODIMP CAccPLV::accDoDefaultAction( VARIANT varChild )
  766. {
  767. //if ( varChild.lVal == CHILDID_SELF )
  768. return m_pDefAccessible->accDoDefaultAction( varChild );
  769. }
  770. //-----------------------------------------------------------------------
  771. // CAccPLV::accSelect()
  772. //-----------------------------------------------------------------------
  773. STDMETHODIMP CAccPLV::accSelect( long flagsSel, VARIANT varChild )
  774. {
  775. return m_pDefAccessible->accSelect(flagsSel, varChild);
  776. }
  777. //-----------------------------------------------------------------------
  778. // CAccPLV::accLocation()
  779. //
  780. // DESCRIPTION:
  781. //
  782. // Implements the IAccessible interface method accLocation().
  783. //
  784. // Retrieves the specified child's current screen location in
  785. // screen coordinates.
  786. //
  787. // PARAMETERS:
  788. //
  789. // pxLeft [out] Address of the child's left most
  790. // boundary.
  791. //
  792. // pyTop [out] Address of the child's upper most
  793. // boundary.
  794. //
  795. // pcxWid [out] Address of the child's width.
  796. //
  797. // pcyHt [out] Address of the child's height.
  798. //
  799. // varChild [in] VARIANT structure that identifies the
  800. // child whose screen location is to be
  801. // retrieved. Since CAccPLV only
  802. // supports child IDs, the vt member
  803. // of this structure must equal VT_I4.
  804. //
  805. // RETURNS:
  806. //
  807. // HRESULT E_INVALIDARG if any of the parameters
  808. // are invalid, E_UNEXPECTED if we are for
  809. // some reason unable to determine the
  810. // window rect of the button or status bar,
  811. // S_OK if the screen coordinates of the
  812. // child are successfully determined, or
  813. // the return value from the standard client
  814. // window implementation of accLocation().
  815. //
  816. //-----------------------------------------------------------------------
  817. STDMETHODIMP CAccPLV::accLocation( long* pxLeft,
  818. long* pyTop,
  819. long* pcxWid,
  820. long* pcyHt,
  821. VARIANT varChild )
  822. {
  823. if (!pxLeft || !pyTop || !pcxWid || !pcyHt)
  824. return E_INVALIDARG;
  825. if ( varChild.lVal == CHILDID_SELF )
  826. return m_pDefAccessible->accLocation( pxLeft, pyTop, pcxWid, pcyHt, varChild );
  827. *pxLeft = *pyTop = *pcxWid = *pcyHt = 0;
  828. static INT index,colIndex,nCol;
  829. static POINT pt;
  830. if(m_lpPlv->dwStyle == PLVSTYLE_ICON) {
  831. *pcxWid = IV_GetItemWidth(m_hWnd);
  832. *pcyHt = IV_GetItemHeight(m_hWnd);
  833. index = varChild.lVal - 1;
  834. nCol = IV_GetCol(m_hWnd);
  835. pt.x = IV_GetXMargin(m_hWnd) + *pcxWid * (index % nCol);
  836. pt.y = IV_GetYMargin(m_hWnd) + *pcyHt * (index / nCol);
  837. ClientToScreen(m_hWnd,&pt);
  838. *pxLeft = pt.x;
  839. *pyTop = pt.y;
  840. return S_OK;
  841. }
  842. else {
  843. nCol = RV_GetColumn(m_lpPlv);
  844. if (nCol < 1)
  845. return E_FAIL;
  846. index = (varChild.lVal - 1) / nCol;
  847. colIndex = (varChild.lVal - 1) % nCol;
  848. if(!index){ //header
  849. *pcyHt = RV_GetHeaderHeight(m_lpPlv);
  850. pt.y = RV_GetYMargin(m_hWnd);
  851. }
  852. else{
  853. *pcyHt = RV_GetItemHeight(m_hWnd);
  854. pt.y = RV_GetYMargin(m_hWnd) + RV_GetHeaderHeight(m_lpPlv)
  855. + ((index - 1) - m_lpPlv->iCurTopIndex) * (*pcyHt);
  856. }
  857. static HD_ITEM hdItem;
  858. hdItem.mask = HDI_WIDTH;
  859. hdItem.fmt = 0;
  860. Header_GetItem(m_lpPlv->hwndHeader,colIndex,&hdItem);
  861. *pcxWid = hdItem.cxy;
  862. pt.x = 0;
  863. for(int i = 0;i<colIndex;i++){
  864. Header_GetItem(m_lpPlv->hwndHeader,i,&hdItem);
  865. pt.x += hdItem.cxy;
  866. }
  867. ClientToScreen(m_hWnd,&pt);
  868. *pxLeft = pt.x;
  869. *pyTop = pt.y;
  870. return S_OK;
  871. }
  872. }
  873. //-----------------------------------------------------------------------
  874. // CAccPLV::accNavigate()
  875. //-----------------------------------------------------------------------
  876. STDMETHODIMP CAccPLV::accNavigate( long navDir, VARIANT varStart, VARIANT* pVarEndUpAt )
  877. {
  878. return m_pDefAccessible->accNavigate( navDir, varStart, pVarEndUpAt );
  879. }
  880. //-----------------------------------------------------------------------
  881. // CAccPLV::accHitTest()
  882. //
  883. // DESCRIPTION:
  884. //
  885. // Implements the IAccessible interface method accHitTest().
  886. //
  887. // Retrieves the ID of the a child at a given point on the screen.
  888. //
  889. // PARAMETERS:
  890. //
  891. // xLeft and yTop [in] The screen coordinates of the point
  892. // to be hit tested.
  893. //
  894. // pVarHit [out] Pointer to the VARIANT structure that
  895. // will contain information describing
  896. // the hit child. If the vt member is
  897. // VT_I4, then the lVal member is a child
  898. // ID. If the vt member is VT_EMPTY,
  899. // then the navigation failed.
  900. //
  901. // RETURNS:
  902. //
  903. // HRESULT E_INVALIDARG if the pVarHit parameter is
  904. // invalid, or S_OK.
  905. //
  906. // NOTES:
  907. //
  908. // Since the CAccPLV object has no child objects (only child
  909. // elements), pVarHit will never be a pointer to a IDispatch
  910. // interface of a child object.
  911. //
  912. //-----------------------------------------------------------------------
  913. STDMETHODIMP CAccPLV::accHitTest( long xLeft, long yTop, VARIANT* pVarHit )
  914. {
  915. if(!PLV_IsMSAAAvailable(m_lpPlv))
  916. return E_FAIL;
  917. if ( !pVarHit )
  918. return E_INVALIDARG;
  919. static POINT pt;
  920. static RECT rc;
  921. static INT index,nCol;
  922. static PLVINFO plvInfo;
  923. static HD_ITEM hdItem;
  924. pt.x = xLeft;
  925. pt.y = yTop;
  926. ScreenToClient(m_hWnd,&pt);
  927. GetClientRect(m_hWnd, &rc );
  928. if (PtInRect( &rc, pt )) {
  929. pVarHit->vt = VT_I4;
  930. pVarHit->lVal = CHILDID_SELF;
  931. #ifdef OLD
  932. if(m_lpPlv->dwStyle == PLVSTYLE_ICON) // iconview
  933. index = IV_GetInfoFromPoint(m_lpPlv, pt, &plvInfo);
  934. else { // report view
  935. nCol = RV_GetColumn(m_lpPlv);
  936. index = RV_GetInfoFromPoint(m_lpPlv, pt, &plvInfo);
  937. if(index < 0) {
  938. if(pt.y > RV_GetHeaderHeight(m_lpPlv)) // out of header
  939. return m_pDefAccessible->accHitTest(xLeft, yTop, pVarHit);
  940. // header
  941. INT wid = 0;
  942. hdItem.mask = HDI_WIDTH;
  943. hdItem.fmt = 0;
  944. for(index = 0;index<nCol;index++){
  945. Header_GetItem(m_lpPlv->hwndHeader,index,&hdItem);
  946. wid += hdItem.cxy;
  947. if(pt.x <= wid)
  948. break;
  949. }
  950. }
  951. else
  952. index = (index + 1) * nCol + plvInfo.colIndex;
  953. }
  954. pVarHit->lVal = index + 1; // 1 origin
  955. #else // new
  956. pVarHit->lVal = PLV_ChildIDFromPoint(m_lpPlv,pt);
  957. if(pVarHit->lVal < 0)
  958. return m_pDefAccessible->accHitTest(xLeft, yTop, pVarHit);
  959. #endif
  960. return S_OK;
  961. }
  962. return m_pDefAccessible->accHitTest(xLeft, yTop, pVarHit);
  963. }
  964. //-----------------------------------------------------------------------
  965. // CAccPLV::put_accName()
  966. //-----------------------------------------------------------------------
  967. STDMETHODIMP CAccPLV::put_accName( VARIANT varChild, BSTR szName )
  968. {
  969. //-----------------------------------------------------
  970. // We don't allow clients to change the name
  971. // property of any child so we simply return
  972. // S_FALSE.
  973. //-----------------------------------------------------
  974. return S_FALSE;
  975. UNREFERENCED_PARAMETER(varChild);
  976. UNREFERENCED_PARAMETER(szName);
  977. }
  978. //-----------------------------------------------------------------------
  979. // CAccPLV::put_accValue()
  980. //-----------------------------------------------------------------------
  981. STDMETHODIMP CAccPLV::put_accValue( VARIANT varChild, BSTR szValue )
  982. {
  983. //-----------------------------------------------------
  984. // We don't allow clients to change the value
  985. // property of the status bar (the only child that
  986. // has a value property) so we simply return S_FALSE.
  987. //-----------------------------------------------------
  988. return S_FALSE;
  989. UNREFERENCED_PARAMETER(varChild);
  990. UNREFERENCED_PARAMETER(szValue);
  991. }
  992. //-----------------------------------------------------------------------
  993. // CAccPLV::LresultFromObject()
  994. //
  995. // DESCRIPTION:
  996. //
  997. // call ::LresultFromObject()
  998. //
  999. // PARAMETERS:
  1000. //
  1001. // wParam [in] wParam of WM_GETOBJECT message
  1002. //
  1003. //-----------------------------------------------------------------------
  1004. LRESULT CAccPLV::LresultFromObject(WPARAM wParam)
  1005. {
  1006. if(!PLV_IsMSAAAvailable(m_lpPlv))
  1007. return E_FAIL;
  1008. return PLV_LresultFromObject(m_lpPlv,IID_IAccessible,wParam,(IAccessible *)this);
  1009. }
  1010. //---- End of ACCPLV.CPP ----