Microsoft KB Archive/131287

-

{| The information in this article applies to: Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT version 3.51 - Microsoft Windows 95 version 4.0 - Microsoft Win32s version 1.3
 * width="100%"|

SUMMARY
The LVS_SHAREIMAGELISTS style is available for listview controls to enable the same image lists to be used with multiple listview controls. There is no equivalent TVS_SHAREIMAGELISTS, however, for the treeview control because treeviews share image lists by default.

MORE INFORMATION
By default, a listview control takes ownership of the image lists associated with it. For listviews, this could be any of three image lists (those with large icons, small icons, or state images). These three image lists are set by calling ListView_SetImageList with the flags LVSIL_NORMAL, LVSIL_SMALL, or LVSIL_STATE respectively. The listview then takes responsibility for destroying these image lists when it is destroyed.

Setting the LVS_SHAREIMAGELISTS style, however, moves ownership of the image lists from the listview control to the application. Because this style assumes that the image lists are shared by multiple listviews, specifying this style requires that the application destroy the image lists when the last listview using them is destroyed. Failure to do so causes a memory leak in the system.

Similarly, because treeviews share image lists by default, an application that associates an image list with a treeview should ensure that the image list is destroyed after the last treeview using it is destroyed. Another way to do this is to first set the treeview's image list to NULL by using TreeView_SetImageList; then destroy the handle to the previous image list returned by the function.
 * }

-

Last reviewed: September 29, 1995

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.