@@ -4426,13 +4426,28 @@ LRESULT CMenuContainer::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
4426
4426
if (m_Options&CONTAINER_SEARCH)
4427
4427
s_SearchMenu=m_hWnd;
4428
4428
s_HotPos=GetMessagePos ();
4429
+ m_pAccessible=NULL ;
4429
4430
if (GetSettingBool (L" EnableAccessibility" ))
4430
4431
{
4431
- m_pAccessible=new CMenuAccessible (this );
4432
+ if (SUCCEEDED (m_pAccessibleContext.CoCreateInstance (CLSID_ContextSwitcher)))
4433
+ {
4434
+ CreateAccessibleData createData={this };
4435
+ ComCallData callData={};
4436
+ callData.pUserDefined =&createData;
4437
+ if (SUCCEEDED (m_pAccessibleContext->ContextCallback (CreateAccessible,&callData,IID_IAccessible,4 ,NULL )))
4438
+ {
4439
+ if (FAILED (CoGetInterfaceAndReleaseStream (createData.pStream ,IID_IAccessible,(void **)&m_pAccessible)))
4440
+ {
4441
+ m_pAccessibleContext=NULL ;
4442
+ }
4443
+ }
4444
+ else
4445
+ {
4446
+ m_pAccessibleContext=NULL ;
4447
+ }
4448
+ }
4432
4449
NotifyWinEvent (EVENT_SYSTEM_MENUPOPUPSTART,m_hWnd,OBJID_CLIENT,CHILDID_SELF);
4433
4450
}
4434
- else
4435
- m_pAccessible=NULL ;
4436
4451
m_pDropTargetProxy=new CDropTargetProxy (this );
4437
4452
RegisterDragDrop (m_hWnd,m_pDropTargetProxy);
4438
4453
if (!m_bSubMenu && s_pFrameworkInputPane)
@@ -4441,6 +4456,23 @@ LRESULT CMenuContainer::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
4441
4456
return 0 ;
4442
4457
}
4443
4458
4459
+ HRESULT __stdcall CMenuContainer::CreateAccessible ( ComCallData *pData )
4460
+ {
4461
+ CreateAccessibleData *pCreateData=(CreateAccessibleData*)pData->pUserDefined ;
4462
+ CComPtr<CMenuAccessible> pAccessible=new CMenuAccessible (pCreateData->pMenu );
4463
+ HRESULT hr=CoMarshalInterThreadInterfaceInStream (IID_IAccessible,pAccessible,&pCreateData->pStream );
4464
+ if (FAILED (hr))
4465
+ {
4466
+ pAccessible->Reset ();
4467
+ }
4468
+ return hr;
4469
+ }
4470
+
4471
+ HRESULT __stdcall CMenuContainer::ReleaseAccessible ( ComCallData *pData )
4472
+ {
4473
+ return CoDisconnectContext (INFINITE);
4474
+ }
4475
+
4444
4476
bool CMenuContainer::GetItemRect ( int index, RECT &rc )
4445
4477
{
4446
4478
if (index >=0 && index <(int )m_Items.size ())
@@ -6111,7 +6143,8 @@ LRESULT CMenuContainer::OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
6111
6143
if (m_pAccessible)
6112
6144
{
6113
6145
NotifyWinEvent (EVENT_SYSTEM_MENUPOPUPEND,m_hWnd,OBJID_CLIENT,CHILDID_SELF);
6114
- m_pAccessible->Reset ();
6146
+ m_pAccessibleContext->ContextCallback (ReleaseAccessible,NULL ,IID_IAccessible,4 ,NULL );
6147
+ m_pAccessibleContext=NULL ;
6115
6148
m_pAccessible=NULL ;
6116
6149
}
6117
6150
if (m_pDropTargetHelper && m_pDragObject)
0 commit comments