public ImageList(Int32 size) { var CLSID_ImageList = Guid.Parse("7C476BA2-02B1-48f4-8048-B24619DDC058"); var refIImageList2 = typeof(IImageList).GUID; var IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046"); var ptr = IntPtr.Zero; //var result = Ole32.CoCreateInstance(ref CLSID_ImageList, IntPtr.Zero, Ole32.CLSCTX.INPROC_SERVER, ref IID_IUnknown, out ptr); ptr = ComCtl32.ImageList_Create(size, size, 0x00000020 | 0x00010000 | 0x00020000, 0, 1); this._ImageList = (IImageList2)Marshal.GetObjectForIUnknown(ptr); this.Handle = ptr; }
public virtual void Dispose(bool disposing) { if (!this._Disposed) { if (this._ImageList != null) { Marshal.ReleaseComObject(this._ImageList); } this._ImageList = null; } this._Disposed = true; }
public void SetSize(int size) { ImageList_Destroy(this.Handle); this._ImageList = Marshal.GetObjectForIUnknown(ImageList_Create(size, size, 0x00020000 | 0x00000020, 30, 30)) as IImageList2; this._ImageList.SetImageCount(3000); //this._ImageList.SetIconSize(size, size); int pi = -1; //this._ImageList.GetImageCount(ref pi); //var obj = (ShellObject)KnownFolders.Windows; //for (int i = 0; i < 30; i++) //{ // var res = this._ImageList.Replace(i, obj.GetShellThumbnail(size).GetHbitmap(), IntPtr.Zero); //} }
public ImageListEx(Int32 size) { var ptr = IntPtr.Zero; this._CurrentSize = size; ptr = ComCtl32.ImageList_Create(size, size, 0x00000020 | 0x00010000 | 0x00020000, 0, 1); this._IImageList = (IImageList2)Marshal.GetObjectForIUnknown(ptr); this.Handle = ptr; this._IconLoadingThread = new Thread(_IconsLoadingThreadRun) { IsBackground = true, Priority = ThreadPriority.Normal }; this._IconLoadingThread.IsBackground = true; this._IconLoadingThread.SetApartmentState(ApartmentState.STA); this._IconLoadingThread.Start(); this._IconCacheLoadingThread = new Thread(_IconCacheLoadingThreadRun) { IsBackground = true, Priority = ThreadPriority.BelowNormal }; this._IconCacheLoadingThread.SetApartmentState(ApartmentState.STA); this._IconCacheLoadingThread.IsBackground = true; this._IconCacheLoadingThread.Start(); this._OverlaysLoadingThread = new Thread(_OverlaysLoadingThreadRun) { IsBackground = true, Priority = ThreadPriority.BelowNormal }; this._OverlaysLoadingThread.SetApartmentState(ApartmentState.STA); this._OverlaysLoadingThread.IsBackground = true; this._OverlaysLoadingThread.Start(); this._UpdateSubitemValuesThread = new Thread(_UpdateSubitemValuesThreadRun) { Priority = ThreadPriority.BelowNormal }; this._UpdateSubitemValuesThread.SetApartmentState(ApartmentState.STA); this._UpdateSubitemValuesThread.IsBackground = true; this._UpdateSubitemValuesThread.Start(); this._RedrawingThread = new Thread(_RedrawingThreadRun) { IsBackground = true, Priority = ThreadPriority.Normal }; this._RedrawingThread.SetApartmentState(ApartmentState.STA); this._RedrawingThread.IsBackground = true; this._RedrawingThread.Start(); var defIconInfo = new Shell32.SHSTOCKICONINFO() { cbSize = (UInt32)Marshal.SizeOf(typeof(Shell32.SHSTOCKICONINFO)) }; Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_APPLICATION, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo); this._ExeFallBackIndex = defIconInfo.iSysIconIndex; Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_SHIELD, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo); this._ShieldIconIndex = defIconInfo.iSysIconIndex; Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_SHARE, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo); this._SharedIconIndex = defIconInfo.iSysIconIndex; Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_FOLDER, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo); this._FolderFallBackIndex = defIconInfo.iSysIconIndex; Shell32.SHGetStockIconInfo(Shell32.SHSTOCKICONID.SIID_DOCNOASSOC, Shell32.SHGSI.SHGSI_SYSICONINDEX, ref defIconInfo); this._DefaultFallBackIndex = defIconInfo.iSysIconIndex; var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); this._VideAddornerWide = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, Path.Combine(basePath, "video_addorner_wide.png")); this._VideAddorner = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, Path.Combine(basePath, "video_addorner.png")); }
public extern static int SHGetImageList(ImageListSize iImageList, ref Guid riid, out IImageList2 ppv);
public virtual void Dispose(bool disposing) { if (!this._Disposed) { if (this._ImageList != null) { Marshal.ReleaseComObject(this._ImageList); } this._ImageList = null; } this._Disposed = true; }
public extern static int SHGetImageList(ImageListSize iImageList, ref Guid riid, out IImageList2 ppv);