protected void HideCheckBox(TV_ITEM tv_item)
 {
     if (tv_item.ItemHandle != IntPtr.Zero)
     {
         // get TreeNode-object, that corresponds to TV_ITEM-object             
         TreeNode currentTN = TreeNode.FromHandle(this, tv_item.ItemHandle);
         HiddenCheckBoxTreeNode hiddenCheckBoxTreeNode = currentTN as HiddenCheckBoxTreeNode;
         // check if it's HiddenCheckBoxTreeNode and             
         // if its checkbox already has been hidden               
         if (hiddenCheckBoxTreeNode != null)
         {
             HandleRef treeHandleRef = new HandleRef(this, Handle);
             // check if checkbox already has been hidden                 
             TV_ITEM currentTvItem = new TV_ITEM();
             currentTvItem.ItemHandle = tv_item.ItemHandle;
             currentTvItem.StateMask = TVIS_STATEIMAGEMASK;
             currentTvItem.State = 0;
             IntPtr res = SendMessage(treeHandleRef, TVM_GETITEM, 0, ref currentTvItem);
             bool needToHide = res.ToInt32() > 0 && currentTvItem.State != 0;
             if (needToHide)
             {
                 // specify attributes to update                     
                 TV_ITEM updatedTvItem = new TV_ITEM();
                 updatedTvItem.ItemHandle = tv_item.ItemHandle;
                 updatedTvItem.Mask = TVIF_STATE;
                 updatedTvItem.StateMask = TVIS_STATEIMAGEMASK;
                 updatedTvItem.State = 0;
                 // send TVM_SETITEM message                     
                 SendMessage(treeHandleRef, TVM_SETITEM, 0, ref updatedTvItem);
             }
         }
     }
 }
        protected void HideCheckBox(TV_ITEM tv_item)
        {
            if (tv_item.ItemHandle != IntPtr.Zero)
            {
                // get TreeNode-object, that corresponds to TV_ITEM-object
                TreeNode currentTN = TreeNode.FromHandle(this, tv_item.ItemHandle);

                Custom_HiddenCheckBoxTreeNode hiddenCheckBoxTreeNode = currentTN as Custom_HiddenCheckBoxTreeNode;
                // check if it's HiddenCheckBoxTreeNode and
                // if its checkbox already has been hidden
                if (hiddenCheckBoxTreeNode != null && !hiddenCheckBoxTreeNode.CheckboxHidden)
                {
                    // to evade repeat hiding, we set CheckboxHidden to  true
                    hiddenCheckBoxTreeNode.CheckboxHidden = true;

                    // specify attributes to update
                    TV_ITEM updatedTvItem = new TV_ITEM();
                    updatedTvItem.ItemHandle = tv_item.ItemHandle;
                    updatedTvItem.Mask = TVIF_STATE;
                    updatedTvItem.StateMask = TVIS_STATEIMAGEMASK;
                    updatedTvItem.State = 0;

                    // send TVM_SETITEM message
                    SendMessage(new HandleRef(this, Handle), TVM_SETITEM, 0, ref updatedTvItem);
                }
            }
        }
        protected void HideCheckBox(TV_ITEM tv_item)
        {
            if (tv_item.ItemHandle != IntPtr.Zero)
            {
                // get TreeNode-object, that corresponds to TV_ITEM-object
                TreeNode currentTN = TreeNode.FromHandle(this, tv_item.ItemHandle);

                Custom_HiddenCheckBoxTreeNode hiddenCheckBoxTreeNode = currentTN as Custom_HiddenCheckBoxTreeNode;
                // check if it's HiddenCheckBoxTreeNode and
                // if its checkbox already has been hidden
                if (hiddenCheckBoxTreeNode != null && !hiddenCheckBoxTreeNode.CheckboxHidden)
                {
                    // to evade repeat hiding, we set CheckboxHidden to  true
                    hiddenCheckBoxTreeNode.CheckboxHidden = true;

                    // specify attributes to update
                    TV_ITEM updatedTvItem = new TV_ITEM();
                    updatedTvItem.ItemHandle = tv_item.ItemHandle;
                    updatedTvItem.Mask       = TVIF_STATE;
                    updatedTvItem.StateMask  = TVIS_STATEIMAGEMASK;
                    updatedTvItem.State      = 0;

                    // send TVM_SETITEM message
                    SendMessage(new HandleRef(this, Handle), TVM_SETITEM, 0, ref updatedTvItem);
                }
            }
        }
        private void SetNodeStateToMixed(TreeNode node)
        {
            var lParam = new TV_ITEM
            {
                mask      = 0x18,       // TVIF_HANDLE | TVIF_STATE
                hItem     = node.Handle,
                stateMask = 0xf000,     // TVIS_STATEIMAGEMASK
                state     = 0x3000
            };
            // ReSharper disable once InconsistentNaming
            const int TVM_SETITEM = 0x110d;

            SendMessage(new HandleRef(this.BackgroundObjectTree, this.BackgroundObjectTree.Handle), TVM_SETITEM, 0, ref lParam);
        }
Exemple #5
0
    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
 
        // trap TVM_SETITEM message
        if (m.Msg == TVM_SETITEM || m.Msg == TVM_SETITEMA || m.Msg == TVM_SETITEMW)
            // check if CheckBoxes are turned on
            if (CheckBoxes)
            {
                // get information about the node
                TV_ITEM tv_item = (TV_ITEM)m.GetLParam(typeof(TV_ITEM));
                HideCheckBox(tv_item);
            }
    }   
        protected void HideCheckBox(TV_ITEM tv_item)
        {
            if (tv_item.ItemHandle != IntPtr.Zero && tv_item.ItemHandle != hidingItemHandle)
            {
                // get TreeNode-object, that corresponds to TV_ITEM-object
                TreeNode currentTN = TreeNode.FromHandle(this, tv_item.ItemHandle);

                HiddenCheckBoxTreeNode hiddenCheckBoxTreeNode = currentTN as HiddenCheckBoxTreeNode;
                // check if it's HiddenCheckBoxTreeNode and
                // if its checkbox already has been hidden

                if (hiddenCheckBoxTreeNode != null)
                {
                    HandleRef treeHandleRef = new HandleRef(this, Handle);

                    // check if checkbox already has been hidden
                    TV_ITEM currentTvItem = new TV_ITEM();
                    currentTvItem.ItemHandle = tv_item.ItemHandle;
                    currentTvItem.StateMask  = TVIS_STATEIMAGEMASK;
                    currentTvItem.State      = 0;

                    IntPtr res        = SendMessage(treeHandleRef, TVM_GETITEM, 0, ref currentTvItem);
                    bool   needToHide = res.ToInt32() > 0 && currentTvItem.State != 0;

                    if (needToHide)
                    {
                        // specify attributes to update
                        TV_ITEM updatedTvItem = new TV_ITEM();
                        updatedTvItem.ItemHandle = tv_item.ItemHandle;
                        updatedTvItem.Mask       = TVIF_STATE;
                        updatedTvItem.StateMask  = TVIS_STATEIMAGEMASK;
                        updatedTvItem.State      = 0;

                        hidingItemHandle = tv_item.ItemHandle;
                        try
                        {
                            // send TVM_SETITEM message
                            SendMessage(treeHandleRef, TVM_SETITEM, 0, ref updatedTvItem);
                        }
                        finally
                        {
                            hidingItemHandle = IntPtr.Zero;
                        }
                    }
                }
            }
        }
Exemple #7
0
        protected void HideCheckBox(TV_ITEM tv_item)
        {
            if (tv_item.ItemHandle != IntPtr.Zero)
            {
                // get TreeNode-object, that corresponds to TV_ITEM-object
                var currentTN = TreeNode.FromHandle(this, tv_item.ItemHandle);

                // check if it's HiddenCheckBoxTreeNode and
                // if its checkbox already has been hidden

                if (currentTN is HiddenCheckBoxTreeNode)
                {
                    var treeHandleRef = new HandleRef(this, Handle);

                    // check if checkbox already has been hidden
                    var currentTvItem = new TV_ITEM
                    {
                        ItemHandle = tv_item.ItemHandle,
                        StateMask  = TVIS_STATEIMAGEMASK,
                        State      = 0
                    };

                    var res        = SendMessage(treeHandleRef, TVM_GETITEM, 0, ref currentTvItem);
                    var needToHide = res.ToInt32() > 0 && currentTvItem.State != 0;

                    if (needToHide)
                    {
                        // specify attributes to update
                        var updatedTvItem = new TV_ITEM
                        {
                            ItemHandle = tv_item.ItemHandle,
                            Mask       = TVIF_STATE,
                            StateMask  = TVIS_STATEIMAGEMASK,
                            State      = 0
                        };

                        // send TVM_SETITEM message
                        SendMessage(treeHandleRef, TVM_SETITEM, 0, ref updatedTvItem);
                    }
                }
            }
        }
Exemple #8
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x0203)             // WM_LBUTTONDBLCLK. dblclick is misbehaving with checkboxes.
            {
                m.Result = IntPtr.Zero;
                return;
            }

            base.WndProc(ref m);

            // trap TVM_SETITEM message
            if (m.Msg == TVM_SETITEM || m.Msg == TVM_SETITEMA || m.Msg == TVM_SETITEMW)
            {
                // check if CheckBoxes are turned on
                if (CheckBoxes)
                {
                    // get information about the node
                    TV_ITEM tv_item = (TV_ITEM)m.GetLParam(typeof(TV_ITEM));
                    HideCheckBox(tv_item);
                }
            }
        }
Exemple #9
0
 public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, ref TV_ITEM lParam);
 public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, ref TV_ITEM lParam);
Exemple #11
0
 internal static extern IntPtr SendMessage(HandleRef hWnd, int Msg, IntPtr wParam, ref TV_ITEM lParam);