Exposing Owner-Drawn List Box Items

Application developers do not need to implement IAccessible to expose the items in an owner-drawn list box that has the style LBS_HASSTRINGS because Microsoft Active Accessibility exposes the items in list boxes with this style. The items in an owner-drawn list box with the LBS_HASSTRINGS style are displayed as text. However, this style is also used with owner-drawn list boxes that do not display text so that the list box items are exposed by Microsoft Active Accessibility.

To allow Microsoft Active Accessibility to expose the items in an owner-drawn list box that does not display text:

  • Use the LBS_HASSTRINGS style when creating the list box.
  • Create a textual counterpart that names or describes each item in the list box.
  • When adding items to the owner-drawn list box, use the LB_ADDSTRING message to add the text that you want Microsoft Active Accessibility to expose. This text is not displayed, so it is not part of the owner-drawn data. Add the owner-drawn item data using the LB_SETITEMDATA message.

When using the above method, note the following:

  • If you use the LBS_SORT style, the list box is sorted using the supplied strings and not the WM_COMPAREITEM callback procedure.
  • With owner-drawn variable list boxes created with the style LBS_OWNERDRAWVARIABLE, use a global variable or some other mechanism to keep track of when the itemData member of the MEASUREITEMSTRUCT is valid. The global variable is needed because the system sends the WM_MEASUREITEM message as soon as the string is added but before the item data is attached, and at this point the itemData member is not valid.
  • To change the string for an item in a list box with the LBS_HASSTRINGS style, delete the item with the LB_DELETESTRING message and add the new string with the LB_ADDSTRING message.

 

 

Show: