Export (0) Print
Expand All

Using Direct Annotation

Dd373677.wedge(en-us,VS.85).gifTo use direct annotation to override the value of a property

  1. Use the CoCreateInstance or CoCreateInstanceEx function to create the IAccPropServices object.
  2. Call IAccPropServices::SetHwndProp, passing the HWND, object ID, child ID, the property to be overridden, and a VARIANT containing the new value of the property. This step annotates the value.
  3. Release the interface pointers and free memory.

The following example shows how to annotate the Role property of a static text control.



HRESULT CMyTextControl::SetAccessibleProperties()
{
  // COM is assumed to be initialized...
  IAccPropServices* pAccPropServices = NULL;

  HRESULT hr = CoCreateInstance(CLSID_AccPropServices,
    NULL, CLSCTX_SERVER, IID_IAccPropServices, 
    (void**)&pAccPropServices);

  if (SUCCEEDED(hr))
  {
    // Annotating the Role of this object to be STATICTEXT
    VARIANT var;
    var.vt = VT_I4;
    var.lVal = ROLE_SYSTEM_STATICTEXT;

    hr = pAccPropServices->SetHwndProp(_hwnd,
      OBJID_CLIENT,
      CHILDID_SELF,
      PROPID_ACC_ROLE,
      var);

    pAccPropServices->Release();
  }
  return hr;
}


Properties Supported When Specifying a Value

The following Microsoft Active Accessibility properties can be annotated when specifying a value (where the value must be of the noted type) for direct annotation. To override or add a Microsoft UI Automation property to a control, you can specify the UI Automation property ID instead of the Microsoft Active Accessibility property ID. For a list of UI Automation IDs, see Property Identifiers.

PropertyType
PROPID_ACC_NAMEVT_BSTR
PROPID_ACC_DESCRIPTIONVT_BSTR
PROPID_ACC_ROLEVT_I4
PROPID_ACC_STATEVT_I4
PROPID_ACC_HELPVT_BSTR
PROPID_ACC_KEYBOARDSHORTCUTVT_BSTR
PROPID_ACC_DEFAULTACTIONVT_BSTR
PROPID_ACC_VALUEMAPVT_BSTR
PROPID_ACC_ROLEMAPVT_BSTR
PROPID_ACC_STATEMAPVT_BSTR

 

 

 

Community Additions

ADD
Show:
© 2014 Microsoft