[Accessibility] Newbie question: help with BSTR arrays

Pete Brunet pete at a11ysoft.com
Tue Feb 23 15:42:40 PST 2010


Hi Brian, I suspect there are some important readers that don't watch
this list. I'm cc'ing it to the IA2 list. -Pete

Brian Cragun wrote:
> Thanks for your interest and patience. The following code seems to be
> working. It shows a CLIENT fragment that calls for the key bindings
> and then pulls them off for processing. The SERVER snippet shows how I
> am building a simple three element BSTR array. Please advise if you
> see any stupid errors being made.
>
> Thanks!
>
> Brian
>
> CLIENT:
> res =
> m_spAccessible2->QueryInterface(IID_IAccessibleAction,(void**)&m_spAccessibleAction);
>
> long nActions = 0L;
> res = m_spAccessibleAction->nActions(&nActions);
> if(SUCCEEDED(res)){
> BSTR name;
> BSTR description;
> for (int iAction=0 ; iAction<nActions; iAction++){
> res = m_spAccessibleAction->get_name(iAction, &name);
> if(SUCCEEDED(res)){
> Process(name); // Process the name and free the string
> }
> res = m_spAccessibleAction->get_description(iAction, &description);
> if(SUCCEEDED(res)){
> Process(description); // Process the name and free the string
> }
>
> BSTR *aKeyBindings;
> long aNumMaxBinding = 10;
> long aNumBindings;
> res = m_spAccessibleAction->get_keyBinding(iAction, aNumMaxBinding,
> &aKeyBindings, &aNumBindings);
> if(SUCCEEDED(res)){
> for (int jBind=0; jBind<aNumBindings; jBind++){
> Process(aKeyBindings[jBind]); // Process the name and free the string
> }
> CoTaskMemFree(aKeyBindings);
> }
>
> }
> }
>
> SERVER:
> STDMETHODIMP AccServer::get_keyBinding(long aActionIndex, long
> aNumMaxBinding,
> BSTR **aKeyBinding,
> long *aNumBinding)
> {
>
> *aKeyBinding = static_cast<BSTR*>(CoTaskMemAlloc((aNumMaxBinding) *
> sizeof(BSTR*)));
> if (!*aKeyBinding) return E_OUTOFMEMORY;
>
> *aKeyBinding[0] = ::SysAllocString(OLESTR("0 key binding"));
> // if (!*(aKeyBinding[0])) return E_OUTOFMEMORY;
> (*aKeyBinding)[1] = ::SysAllocString(OLESTR("1 key binding"));
> // if (!*(aKeyBinding[1])) return E_OUTOFMEMORY;
> (*aKeyBinding)[2] = ::SysAllocString(OLESTR("2 key binding"));
> // if (!*(aKeyBinding[2])) return E_OUTOFMEMORY;
> *aNumBinding = 3L;
> return S_OK;
> }
>
>
>
> Brian Cragun
> IBM AbilityLab Consultant
> Human Ability & Accessibility Center_
> __www.ibm.com/able_ <http://www.ibm.com/able> & _w3.ibm.com/able_
> <http://w3.ibm.com/able>
> W:(720)-663-2801 H:(507)288-2437
>
> */Subscribe to RSS feed and contribute to/**/Accessibility News
> community/*
> <http://w3.ibm.com/connections/communities/service/html/communityview?communityUuid=136047f0-6cda-4a2a-9a90-2188047a542a>*/on
> Connections/*
> _IBM Accessibility_ <http://www.facebook.com/IBMAccessibility> on
> Facebook ▼ _IBMAccess_ <http://twitter.com/IBMAccess> on Twitter ▼
> _IBM Accessibility_ <http://www.linkedin.com/e/vgh/2419815/> on LinkedIn
>
>
>
> From: 	Brian Cragun/Rochester/IBM at IBMUS
> To: 	accessibility at lists.linux-foundation.org
> Date: 	02/22/2010 01:52 PM
> Subject: 	[Accessibility] Newbie question: help with BSTR arrays
> Sent by: 	accessibility-bounces at lists.linux-foundation.org
>
>
> ------------------------------------------------------------------------
>
>
>
> I'm struggling to understand how a BSTR array is properly allocated
> and content is added to it. Also how the BSTRs in the array are
> retrieved. Does anyone have any simple examples?
>
> The information at
> _http://accessibility.freestandards.org/a11yspecs/ia2/docs/html/_generalinfo.html#_arrayConsideration_
> is useful but not quite enough for me.
> I assume I need to allocation the memory with *CoTaskMemAlloc* and
> release it with *CoTaskMemFree. *
> *
> Thanks!*
> *
> - Brian*
>
> Brian Cragun
> IBM AbilityLab Consultant
> Human Ability & Accessibility Center_
> __www.ibm.com/able_ <http://www.ibm.com/able> & _w3.ibm.com/able_
> <http://w3.ibm.com/able>
> W:(720)-663-2801 H:(507)288-2437
> _______________________________________________
> Accessibility mailing list
> Accessibility at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/accessibility
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Accessibility mailing list
> Accessibility at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/accessibility
>   

-- 
*Pete Brunet*

a11ysoft - Accessibility Architecture and Development
(512) 238-6967 (work), (512) 689-4155 (cell)
Skype: pete.brunet
IM: ptbrunet (AOL, Google), ptbrunet at live.com (MSN)
http://www.a11ysoft.com/about/
Ionosphere: WS4G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux-foundation.org/pipermail/accessibility/attachments/20100223/405bdd90/attachment-0001.htm 


More information about the Accessibility mailing list