Ejemplo n.º 1
0
        /// <summary>
        /// Associates a SysImageList with a TreeView control
        /// </summary>
        /// <param name="treeView">TreeView control to associated ImageList with</param>
        /// <param name="sysImageList">System Image List to associate</param>
        /// <param name="forStateImages">Whether to add ImageList as StateImageList</param>
        public static void SetTreeViewImageList(
            TreeView treeView,
            SystemImageList sysImageList,
            bool forStateImages
            )
        {
            IntPtr wParam = (IntPtr)TVSIL_NORMAL;

            if (forStateImages)
            {
                wParam = (IntPtr)TVSIL_STATE;
            }
            SendMessage(
                treeView.Handle,
                TVM_SETIMAGELIST,
                wParam,
                sysImageList.Handle);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Associates a SysImageList with a ListView control
        /// </summary>
        /// <param name="listView">ListView control to associate ImageList with</param>
        /// <param name="sysImageList">System Image List to associate</param>
        /// <param name="forStateImages">Whether to add ImageList as StateImageList</param>
        public static void SetListViewImageList(
            ListView listView,
            SystemImageList sysImageList,
            bool forStateImages
            )
        {
            IntPtr wParam = (IntPtr)LVSIL_NORMAL;

            if (sysImageList.ImageListSize == SystemImageListSize.SmallIcons)
            {
                wParam = (IntPtr)LVSIL_SMALL;
            }
            if (forStateImages)
            {
                wParam = (IntPtr)LVSIL_STATE;
            }
            SendMessage(
                listView.Handle,
                LVM_SETIMAGELIST,
                wParam,
                sysImageList.Handle);
        }