Düzenle

Aracılığıyla paylaş


Using Direct Annotation

To 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.

Property Type
PROPID_ACC_NAME VT_BSTR
PROPID_ACC_DESCRIPTION VT_BSTR
PROPID_ACC_ROLE VT_I4
PROPID_ACC_STATE VT_I4
PROPID_ACC_HELP VT_BSTR
PROPID_ACC_KEYBOARDSHORTCUT VT_BSTR
PROPID_ACC_DEFAULTACTION VT_BSTR
PROPID_ACC_VALUEMAP VT_BSTR
PROPID_ACC_ROLEMAP VT_BSTR
PROPID_ACC_STATEMAP VT_BSTR