Microsoft KB Archive/196205

{|
 * width="100%"|

HOWTO: Expose Owner-drawn List Boxes by Active Accessibility

 * }

Q196205

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), on platform(s):
 * the operating system: Microsoft Windows NT 4.0
 * Microsoft Windows 98
 * Microsoft Windows 95

-

SUMMARY
You can use Active Accessibility tools to obtain information from owner- drawn list boxes. When you create an owner-drawn list box, use the LBS_HASSTRINGS style. Use the LB_ADDSTRING message to add the text that is exposed to Active Accessibility clients. This text must not be the owner- drawn data. Use the LB_SETITEMDATA message to attach owner-drawn data to the list box.

This method allows for both the owner-drawn data and the text string to co-exist in the list box. If you need to change the code, you only need to change LB_GETTEXT to LB_GETITEMDATA to get the owner-drawn data.

MORE INFORMATION
Important Notes:


 * If you use the LBS_SORT style, the list box is sorted using the supplied strings and not the WM_COMPAREITEM callback.
 * With owner-drawn variable lists, you should use a global variable or some other mechanism to keep track of when the itemdata member of the MEASUREITEMSTRUCT is valid. You need the global variable because Windows sends the WM_MEASUREITEM message as soon as the string is added, but before the item data has been attached. At this point, the itemdata member of the MEASUREITEMSTRUCT is not valid.
 * Additional precautions are required if you use advanced owner-draw methods such as changing the names of items or rearranging the items. One example is the old technique of using an owner-drawn list box to create a control that collapses and expands like a tree view control. List boxes do not allow you to change item strings. Therefore, to obtain the same result, you must delete the item and insert it with the new string name.

This information applies only to Windows 95, Windows 98, and Windows NT 4.0 Service Pack 4 and later versions.