예제 #1
0
        public static void UseSystemImageList(ListView control)
        {
            IntPtr large, small;
            int    x, y;

            if (control.LargeImageList == null)
            {
                control.LargeImageList = new ImageList();
            }

            if (control.SmallImageList == null)
            {
                control.SmallImageList = new ImageList();
            }

            Shell32.FileIconInit(true);
            if (!Shell32.Shell_GetImageLists(out large, out small))
            {
                throw new Exception("Failed to get system image list");
            }

            ComCtl32.ImageList_GetIconSize(large, out x, out y);
            control.LargeImageList.ImageSize = new Size(x, y);
            ComCtl32.ImageList_GetIconSize(small, out x, out y);
            control.SmallImageList.ImageSize = new Size(x, y);

            User32.SendMessage(control.Handle, MSG.LVM_SETIMAGELIST,
                               (int)LVSIL.LVSIL_NORMAL, LargeImageList);
            User32.SendMessage(control.Handle, MSG.LVM_SETIMAGELIST,
                               (int)LVSIL.LVSIL_SMALL, SmallImageList);
        }
예제 #2
0
 static void InitializeImageLists()
 {
     Shell32.FileIconInit(true);
     if (!Shell32.Shell_GetImageLists(out m_LargeImageList, out m_SmallImageList))
     {
         throw new Exception("Failed to get system image list");
     }
 }