Ejemplo n.º 1
0
        private void SetNodeImage(TreeNode node)
        {
            var itemInfo = new TVITEMW();
            var folder   = (ShellItem)node.Tag;

            // We need to set the images for the item by sending a
            // TVM_SETITEMW message, as we need to set the overlay images,
            // and the .Net TreeView API does not support overlays.
            itemInfo.mask = TVIF.TVIF_IMAGE | TVIF.TVIF_SELECTEDIMAGE |
                            TVIF.TVIF_STATE;
            itemInfo.hItem  = node.Handle;
            itemInfo.iImage = folder.GetSystemImageListIndex(
                ShellIconType.SmallIcon, ShellIconFlags.OverlayIndex);
            itemInfo.iSelectedImage = folder.GetSystemImageListIndex(
                ShellIconType.SmallIcon, ShellIconFlags.OpenIcon);
            itemInfo.state     = (TVIS)(itemInfo.iImage >> 16);
            itemInfo.stateMask = TVIS.TVIS_OVERLAYMASK;
            User32.SendMessage(_mTreeView.Handle, MSG.TVM_SETITEMW,
                               0, ref itemInfo);
        }
Ejemplo n.º 2
0
        void SetNodeImage(IntPtr node, ShellItem sho, IntPtr m_TreeViewHandle)
        {
            var pidl = sho.Pidl;


            TVITEMW   itemInfo = new TVITEMW();
            ShellItem folder   = sho;

            // We need to set the images for the item by sending a
            // TVM_SETITEMW message, as we need to set the overlay images,
            // and the .Net TreeView API does not support overlays.
            itemInfo.mask = TVIF.TVIF_IMAGE | TVIF.TVIF_SELECTEDIMAGE |
                            TVIF.TVIF_STATE;
            itemInfo.hItem  = node;
            itemInfo.iImage = ShellItem.GetSystemImageListIndex(pidl,
                                                                ShellIconType.SmallIcon, ShellIconFlags.OverlayIndex);
            itemInfo.iSelectedImage = ShellItem.GetSystemImageListIndex(pidl,
                                                                        ShellIconType.SmallIcon, ShellIconFlags.OpenIcon);
            itemInfo.state     = (TVIS)(itemInfo.iImage >> 16);
            itemInfo.stateMask = TVIS.TVIS_OVERLAYMASK;

            User32.SendMessage(m_TreeViewHandle, MSG.TVM_SETITEMW,
                               0, ref itemInfo);
        }