Пример #1
0
        public ImageList(ImageListSize size)
        {
            this._Size       = size;
            this._SizePixels = new Lazy <Int32Size>(this.GetSizePixels);
            var hresult = Win32Api.SHGetImageList(size, ref IID_ImageList2, out this._ImageList);

            Marshal.ThrowExceptionForHR(hresult);
        }
Пример #2
0
        public ImageList(ImageListSize size)
        {
            //this._Size = size;
            //this._SizePixels = new Lazy<Int32Size>(this.GetSizePixels);
            var handle  = IntPtr.Zero;
            var hresult = Win32Api.SHGetImageList(size, ref IID_ImageList2, out this._ImageList);

            Win32Api.SHGetImageListHandle(size, ref IID_ImageList2, ref handle);
            this.Handle = handle;
            Marshal.ThrowExceptionForHR(hresult);
        }
Пример #3
0
            /*private const int TV_FIRST = 0x1100;
             * private const int TVM_SETIMAGELIST = (TV_FIRST + 9);
             *
             * private const int TVSIL_NORMAL = 0;
             * private const int TVSIL_STATE = 2;*/

            /*public static int ReleaseImageList(object imageList)
             * {
             * if (imageList != null)
             *  return Marshal.ReleaseComObject(imageList);
             * return -1;
             * }*/
            /// <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 SetListViewSystemImageList(ListView listView, ImageListSize imageListSize, bool forStateImages)
            {
                //object res = null;
                if (listView != null)
                {
                    // Get the System IImageList object from the Shell:
                    Guid iidImageList = new Guid(IIMAGELIST_GUID_STRING);
                    //IImageList iImageList = null;
                    IntPtr hIml = IntPtr.Zero;
                    //int ret = SHGetImageList(imageListSize, ref iidImageList, ref iImageList);
                    int ret = NativeMethods.SHGetImageList(imageListSize, ref iidImageList, ref hIml);
                    if (ret == 0)
                    {
                        //IntPtr hIml = IntPtr.Zero;
                        // the image list handle is the IUnknown pointer, but
                        // using Marshal.GetIUnknownForObject doesn't return
                        // the right value.  It really doesn't hurt to make
                        // a second call to get the handle:
                        //ret = SHGetImageListHandle(imageListSize, ref iidImageList, ref hIml);
                        //if (ret == 0)
                        //{
                        int wParam = LVSIL_NORMAL;
                        if ((imageListSize == ImageListSize.SHIL_SMALL) || (imageListSize == ImageListSize.SHIL_SYSSMALL))
                        {
                            wParam = LVSIL_SMALL;
                        }
                        if (forStateImages)
                        {
                            wParam = LVSIL_STATE;
                        }
                        NativeMethods.SendMessage(
                            listView.Handle,
                            LVM_SETIMAGELIST,
                            (IntPtr)wParam,
                            hIml);
                        //res = hIml;
                        //}
                        //else
                        //  ReleaseImageList(iImageList);
                    }
                }
                //return res;
            }
Пример #4
0
 public extern static int SHGetImageListHandle(
     ImageListSize iImageList,
     ref Guid riid,
     ref IntPtr handle
     );
Пример #5
0
 public extern static int SHGetImageList(ImageListSize iImageList, ref Guid riid, out IImageList2 ppv);
Пример #6
0
 internal static extern int SHGetImageList(ImageListSize iImageList, ref Guid riid, ref IntPtr handle);
Пример #7
0
		public ImageList(ImageListSize size) {
			//this._Size = size;
			//this._SizePixels = new Lazy<Int32Size>(this.GetSizePixels);
			var handle = IntPtr.Zero;
			var hresult = Win32Api.SHGetImageList(size, ref IID_ImageList2, out this._ImageList);
			Win32Api.SHGetImageListHandle(size, ref IID_ImageList2, ref handle);
			this.Handle = handle;
			Marshal.ThrowExceptionForHR(hresult);
		}
Пример #8
0
		public extern static int SHGetImageListHandle(
								 ImageListSize iImageList,
								 ref Guid riid,
								 ref IntPtr handle
								 );
Пример #9
0
		public extern static int SHGetImageList(ImageListSize iImageList, ref Guid riid, out IImageList2 ppv);