Name 属性Name Property

Name 属性是一个字符串,客户端使用它来识别、查找或公布用户的对象。The Name property is a string used by clients to identify, find, or announce an object for the user. 所有对象均支持 Name 属性。All objects support the Name property.

例如,按钮控件上的文本是其名称,而列表框或编辑控件的名称是紧跟在控件的 tab 键顺序中的静态文本。For example, the text on a button control is its name, while the name for a list box or edit control is the static text that immediately precedes the control in the tabbing order. 即使图形对象不显示名称,也会在查询 name 属性时提供文本。Even graphic objects that do not display a name provide text when queried for the Name property.

通过调用 IAccessible:: get _ AccName检索 名称 属性。The Name property is retrieved by calling IAccessible::get_accName.

选择名称Selecting Names

对象的名称应是直观的,以便用户了解对象的含义或用途。An object's name should be intuitive so that users understand the object's meaning or purpose. 此外, Name 属性相对于父对象中的任何同级对象应是唯一的。Also, the Name property should be unique relative to any sibling objects in the parent.

在表中导航为某些用户带来了特别困难的问题。Navigation within tables presents especially difficult problems for some users. 因此,服务器开发人员应将表的单元名称设置为描述性名称。Therefore, server developers should make table cell names as descriptive as possible. 例如,您可以通过将其所占据的行和列的名称(如 "A1")来创建单元名称。For example, you could create a cell name by combining the names of the row and column it occupies, such as "A1." 不过,最好使用更具说明性的名称,例如 "南希"、"南希" 和 "二月份",其中 "南希" 是当前行,"二月份" 是当前列。However, it is generally better to use more descriptive names, such as "Nancy, February" where "Nancy" is the current row and "February" is the current column.

委托请求Delegating Requests

如果对象不具有对其 Name 属性的访问权限,则它会将请求委托给其父级,并按其子 ID 进行标识。If an object does not have access to its Name property, it delegates requests to its parent, identifying itself by its child ID. 例如,如果客户端调用编辑控件的 Name 属性,则编辑控件将查询委托给其父对象,这将返回标记编辑控件的静态文本控件的值。For example, if a client calls an edit control's Name property, the edit control delegates the query to its parent, which returns the value of the static text control that labels the edit control.