Example #1
0
 public static void SetHasChildren(TreeNode node, bool hasChildren)
 {
     TVITEM item = new TVITEM();
     item.mask = TreeViewItemFlags.CHILDREN;
     item.hItem = node.Handle;
     item.cChildren = hasChildren ? 1 : 0;
     SendMessage(node.TreeView.Handle, TVM_SETITEMA, 0, ref item);
 }
 /// <summary>
 /// Hides the checkbox for the specified node on a TreeView control.
 /// </summary>
 public static void HideCheckBox(this TreeNode node)
 {
     TVITEM tvi = new TVITEM();
     tvi.hItem = node.Handle;
     tvi.mask = TVIF_STATE;
     tvi.stateMask = TVIS_STATEIMAGEMASK;
     tvi.state = 0;
     SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
 }
Example #3
0
        private void HideCheckBox(TreeNode node)
        {
            TVITEM tvi = new TVITEM();

            tvi.hItem     = node.Handle;
            tvi.mask      = TVIF_STATE;
            tvi.stateMask = TVIS_STATEIMAGEMASK;
            tvi.state     = 0;
            IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));

            Marshal.StructureToPtr(tvi, lparam, false);
            SendMessage(this.file_list.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
        }
Example #4
0
        string GetItemText(IntPtr hTreeItem)
        {
            string text;
            TVITEM tvi = new TVITEM();

            tvi.hItem      = hTreeItem;
            tvi.mask       = (int)TreeViewItemFlags.TVIF_TEXT;
            tvi.cchTextMax = 80;
            tvi.pszText    = Marshal.AllocHGlobal(80);
            WindowsAPI.SendMessage(Handle, (int)TreeViewMessages.TVM_GETITEMW, 0, ref tvi);
            text = Marshal.PtrToStringAuto(tvi.pszText);
            return(text);
        }
Example #5
0
 public static IntPtr TreeView_SetItemState(HandleRef hwndTV, IntPtr hti, uint data, uint _mask)
 {
     TVITEM _ms_TVi = new TVITEM();
     _ms_TVi.mask = (uint)TVIF.TVIF_STATE;
     _ms_TVi.hItem = (hti);
     _ms_TVi.stateMask = (_mask);
     _ms_TVi.state = (data);
     IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf(_ms_TVi));
     Marshal.StructureToPtr(_ms_TVi, p, false);
     IntPtr r = SendMessage(hwndTV, (int)TVM.TVM_SETITEMW, IntPtr.Zero, p);
     Marshal.FreeCoTaskMem(p);
     return r;
 }
Example #6
0
        public static uint GetTreeViewOverlay(TreeNode node)
        {
            var tvi = new TVITEM
            {
                mask      = Win32.TVIF_STATE,
                hItem     = node.Handle,
                stateMask = Win32.TVIS_OVERLAYMASK,
                state     = 0
            };
            var ret = Win32.SendMessage(node.TreeView.Handle, Win32.TVM_GETITEMW, 0, ref tvi);

            return(tvi.state >> 8);
        }
Example #7
0
        public static bool GetTreeViewText(IntPtr AHandle, List <string> AOutput)
        {
            if (AOutput == null)
            {
                return(false);
            }
            uint vProcessId;

            GetWindowThreadProcessId(AHandle, out vProcessId);

            IntPtr vProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ |
                                          PROCESS_VM_WRITE, false, vProcessId);
            IntPtr vPointer = VirtualAllocEx(vProcess, IntPtr.Zero, 4096,
                                             MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);

            try
            {
                uint   vItemCount = TreeView_GetCount(AHandle);
                IntPtr vTreeItem  = TreeView_GetRoot(AHandle);
                Console.WriteLine(vItemCount);
                for (int i = 0; i < vItemCount; i++)
                {
                    byte[]   vBuffer = new byte[256];
                    TVITEM[] vItem   = new TVITEM[1];
                    vItem[0]            = new TVITEM();
                    vItem[0].mask       = TVIF_TEXT;
                    vItem[0].hItem      = vTreeItem;
                    vItem[0].pszText    = (IntPtr)((int)vPointer + Marshal.SizeOf(typeof(TVITEM)));
                    vItem[0].cchTextMax = vBuffer.Length;
                    uint vNumberOfBytesRead = 0;
                    WriteProcessMemory(vProcess, vPointer,
                                       Marshal.UnsafeAddrOfPinnedArrayElement(vItem, 0),
                                       Marshal.SizeOf(typeof(TVITEM)), ref vNumberOfBytesRead);
                    SendMessage(AHandle, TVM_GETITEMA, 0, (int)vPointer);
                    ReadProcessMemory(vProcess,
                                      (IntPtr)((int)vPointer + Marshal.SizeOf(typeof(TVITEM))),
                                      Marshal.UnsafeAddrOfPinnedArrayElement(vBuffer, 0),
                                      vBuffer.Length, ref vNumberOfBytesRead);
                    Console.WriteLine(Marshal.PtrToStringAnsi(
                                          Marshal.UnsafeAddrOfPinnedArrayElement(vBuffer, 0)));

                    vTreeItem = TreeNodeGetNext(AHandle, vTreeItem);
                }
            }
            finally
            {
                VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE);
                CloseHandle(vProcess);
            }
            return(true);
        }
Example #8
0
        private static void UncheckNode(IntPtr handle, int hItem)
        {
            if (hItem > 0)
            {
                TVITEM tvi = new TVITEM();

                tvi.mask      = (uint)CommCtrl.TVIF_HANDLE | (uint)CommCtrl.TVIF_STATE;
                tvi.hItem     = new IntPtr(hItem);
                tvi.stateMask = (uint)CommCtrl.TVIS_STATEIMAGEMASK;
                tvi.state     = 0;

                User32.SendMessage(handle, CommCtrl.TVM_SETITEM, IntPtr.Zero, ref tvi);
            }
        }
Example #9
0
        public static void SetTreeViewOverlay(TreeNode node, uint overlayIndex)
        {
            // TreeView_SetItemState(node.TreeView.Handle, node.Handle,
            //     overlayIndex << 8, TVIS_OVERLAYMASK); 相当の処理
            var tvi = new TVITEM
            {
                mask      = Win32.TVIF_STATE,
                hItem     = node.Handle,
                stateMask = Win32.TVIS_OVERLAYMASK,
                state     = (overlayIndex << 8)
            };

            Win32.SendMessage(node.TreeView.Handle, Win32.TVM_SETITEMW, 0, ref tvi);
        }
Example #10
0
        private void HideCheckBox(TreeView tvw, TreeNode node)
        {
            TVITEM tvi = new TVITEM();

            tvi.hItem = node.Handle;

            tvi.mask = TVIF_STATE;

            tvi.stateMask = TVIS_STATEIMAGEMASK;

            tvi.state = 0;

            SendMessage(tvw.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
        }
Example #11
0
        public void SetNodeCheckState(TreeNode node, NodeCheckState checkState)
        {
            if (node.TreeView != this)
            {
                return;
            }

            TVITEM item = new TVITEM();

            item.mask      = TreeViewItemFlags.STATE | TreeViewItemFlags.HANDLE;
            item.stateMask = 0xF000;
            item.state     = (int)checkState << 12;
            item.hItem     = node.Handle;
            Win32Declarations.SendMessage(Handle, TreeViewMessage.TVM_SETITEMA, 0, ref item);
        }
Example #12
0
        protected void SetNodeSelectedState(TreeNode node, bool selected)
        {
            if (node.TreeView != this)
            {
                return;
            }

            TVITEM item = new TVITEM();

            item.mask      = TreeViewItemFlags.STATE | TreeViewItemFlags.HANDLE;
            item.stateMask = (int)TreeViewItemState.SELECTED;
            item.state     = selected ? item.stateMask : 0;
            item.hItem     = node.Handle;
            Win32Declarations.SendMessage(Handle, TreeViewMessage.TVM_SETITEMA, 0, ref item);
        }
Example #13
0
    public static IntPtr TreeView_SetItemState(HandleRef hwndTV, IntPtr hti, uint data, uint _mask)
    {
        TVITEM _ms_TVi = new TVITEM();

        _ms_TVi.mask      = (uint)TVIF.TVIF_STATE;
        _ms_TVi.hItem     = (hti);
        _ms_TVi.stateMask = (_mask);
        _ms_TVi.state     = (data);
        IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf(_ms_TVi));

        Marshal.StructureToPtr(_ms_TVi, p, false);
        IntPtr r = SendMessage(hwndTV, (int)TVM.TVM_SETITEMW, IntPtr.Zero, p);

        Marshal.FreeCoTaskMem(p);
        return(r);
    }
Example #14
0
        public void SetTreeNodeState(TriStateTreeNode node, CheckBoxState state)
        {
            if (node == null)
            {
                return;
            }

            TVITEM tvItem = new TVITEM();

            tvItem.mask      = TVIF_HANDLE | TVIF_STATE;
            tvItem.hItem     = node.Handle;
            tvItem.stateMask = TVIS_STATEIMAGEMASK;
            //State image index in bits 12..15
            tvItem.state = ((int)state) << 12;

            SendMessage(this.Handle, TVM_SETITEM, 0, ref tvItem);
        }
Example #15
0
 // Hide TreeView CheckBox Code
 // --------------------------------------------------------------------------
 #region Hide TreeView CheckBox Code
 static public void ShowCheckBox(TreeNode treeNode, bool show = true)
 {
     if (treeNode.TreeView == null)
     {
         return;
     }
     else
     {
         TVITEM tvi = new TVITEM();
         tvi.hItem     = treeNode.Handle;
         tvi.mask      = TVIF_STATE;
         tvi.stateMask = TVIS_STATEIMAGEMASK;
         tvi.state     = 0;
         IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));
         Marshal.StructureToPtr(tvi, lparam, false);
         SendMessage(treeNode.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
     }
 }
Example #16
0
        public string GetItemText(IntPtr handle)
        {
            TVITEM tvi = new TVITEM();

            const int maxSize = 260;
            IntPtr    pszText = LocalAlloc(0x40, maxSize);

            tvi.mask       = TVIF_TEXT;
            tvi.hItem      = handle;
            tvi.cchTextMax = 260;
            tvi.pszText    = pszText;

            SendMessageTVI(Handle, TVM_GETITEM, IntPtr.Zero, ref tvi);
            string nodeText = Marshal.PtrToStringAnsi(tvi.pszText, maxSize);

            LocalFree(pszText);

            return(nodeText?.TrimEnd('\0'));
        }
Example #17
0
        private void HideCheckBox(TreeNode node)
        {
            TVITEM tvi = new TVITEM
            {
                hItem          = node.Handle,
                mask           = TVIF_STATE,
                stateMask      = TVIS_STATEIMAGEMASK,
                state          = 0,
                lpszText       = null,
                cchTextMax     = 0,
                iImage         = 0,
                iSelectedImage = 0,
                cChildren      = 0,
                lParam         = IntPtr.Zero
            };
            IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));

            Marshal.StructureToPtr(tvi, lparam, false);
            SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
        }
Example #18
0
        private void RemoveCheckboxOnNode(TreeNode node)
        {
            TVITEM tvItem = new TVITEM();

            tvItem.hItem     = node.Handle;
            tvItem.mask      = TVIF_STATE;
            tvItem.stateMask = TVIS_STATEIMAGEMASK;
            tvItem.state     = 0;
            IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvItem));

            try
            {
                Marshal.StructureToPtr(tvItem, lparam, false);
                SendMessage(_groupsTreeView.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
            }
            finally
            {
                Marshal.FreeHGlobal(lparam);
            }
        }
Example #19
0
		/// <summary>
		/// Associates an overlay image with a tree node. The overlay image is taken from the normal
		/// image list of the tree view the node is contained in. Also the overlay image must have been
		/// made available by <see cref="SetOverlayImage(ImageList,int,int)"/>.
		/// </summary>
		/// <param name="node">node to associate the overlay with</param>
		/// <param name="overlayIndex">index between 1 and 5 indicating the overlay image to use or 0 to indicate no image</param>
		public static void SetOverlayIndex(TreeNode node, int overlayIndex)
		{
			if (overlayIndex < 0 || overlayIndex > 5)
				throw new ArgumentOutOfRangeException("overlayIndex", overlayIndex, "overlay image must be between 0 and 5");

			TVITEM tvi = new TVITEM();

			// Define the item we want to set the State in.
			tvi.hItem = node.Handle;

			tvi.mask = TVIF_HANDLE | TVIF_STATE;

			// Left shift 8 to put info in bits 8 to 11
			tvi.state = (uint)overlayIndex << 8;

			// activate the overlay information
			tvi.stateMask = TVIS_OVERLAYMASK;

			// Send the TVM_SETITEM message.
			SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
		}
Example #20
0
        public bool Find(String name, out IntPtr foundItem, out IntPtr previousSelected)
        {
            IntPtr item = (IntPtr)SendMessage(r_hwnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);

            foundItem        = IntPtr.Zero;
            previousSelected = IntPtr.Zero;
            while (item != IntPtr.Zero)
            {
                TVITEM tvItem  = new TVITEM();
                IntPtr pszText = LocalAlloc(0x40, MY_MAXLVITEMTEXT);
                tvItem.hItem      = item;
                tvItem.cchTextMax = MY_MAXLVITEMTEXT;
                tvItem.pszText    = (int)pszText;
                tvItem.stateMask  = TVIS_SELECTED;
                tvItem.mask       = TVIF_TEXT | TVIF_STATE;

                int    bGetItemPtr = SendMessageTVI(r_hwnd, TVM_GETITEM, 0, ref tvItem);
                String buffer      = Marshal.PtrToStringUni((IntPtr)tvItem.pszText, MY_MAXLVITEMTEXT);
                LocalFree(pszText);

                int len = buffer.IndexOf('\0');
                if (len > 0)
                {
                    buffer = buffer.Substring(0, len);
                }
                buffer = buffer.Trim();
                if (buffer == name)
                {
                    foundItem = item;
                }
                else if ((tvItem.state & TVIS_SELECTED) == TVIS_SELECTED)
                {
                    previousSelected = item;
                }
                item = (IntPtr)SendMessage(r_hwnd, TVM_GETNEXTITEM, TVGN_NEXT, (uint)item.ToInt32());
            }
            return(foundItem != IntPtr.Zero);
        }
Example #21
0
        /// <summary>
        /// Associates an overlay image with a tree node. The overlay image is taken from the normal
        /// image list of the tree view the node is contained in. Also the overlay image must have been
        /// made available by <see cref="SetOverlayImage(ImageList,int,int)"/>.
        /// </summary>
        /// <param name="node">node to associate the overlay with</param>
        /// <param name="overlayIndex">index between 1 and 5 indicating the overlay image to use or 0 to indicate no image</param>
        public static void SetOverlayIndex(TreeNode node, int overlayIndex)
        {
            if (overlayIndex < 0 || overlayIndex > 5)
            {
                throw new ArgumentOutOfRangeException("overlayIndex", overlayIndex, "overlay image must be between 0 and 5");
            }

            TVITEM tvi = new TVITEM();

            // Define the item we want to set the State in.
            tvi.hItem = node.Handle;

            tvi.mask = TVIF_HANDLE | TVIF_STATE;

            // Left shift 8 to put info in bits 8 to 11
            tvi.state = (uint)overlayIndex << 8;

            // activate the overlay information
            tvi.stateMask = TVIS_OVERLAYMASK;

            // Send the TVM_SETITEM message.
            SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
        }
Example #22
0
        public bool Find(String name, out IntPtr foundItem, out IntPtr previousSelected)
        {
            IntPtr item = (IntPtr)SendMessage(r_hwnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
            foundItem = IntPtr.Zero;
            previousSelected = IntPtr.Zero;
            while (item != IntPtr.Zero)
            {
                TVITEM tvItem = new TVITEM();
                IntPtr pszText = LocalAlloc(0x40, MY_MAXLVITEMTEXT);
                tvItem.hItem = item;
                tvItem.cchTextMax = MY_MAXLVITEMTEXT;
                tvItem.pszText = (int)pszText;
                tvItem.stateMask = TVIS_SELECTED;
                tvItem.mask = TVIF_TEXT | TVIF_STATE;

                int bGetItemPtr = SendMessageTVI(r_hwnd, TVM_GETITEM, 0, ref tvItem);
                String buffer = Marshal.PtrToStringUni((IntPtr)tvItem.pszText, MY_MAXLVITEMTEXT);
                LocalFree(pszText);

                int len = buffer.IndexOf('\0');
                if (len > 0)
                {
                    buffer = buffer.Substring(0, len);
                }
                buffer = buffer.Trim();
                if (buffer == name)
                {
                    foundItem = item;
                }
                else if ((tvItem.state & TVIS_SELECTED) == TVIS_SELECTED)
                {
                    previousSelected = item;
                }
                item = (IntPtr)SendMessage(r_hwnd, TVM_GETNEXTITEM, TVGN_NEXT, (uint)item.ToInt32());
            }
            return foundItem != IntPtr.Zero;
        }
        /// <summary>
        /// Sets a value indicating if the checkbox is visible on the tree node.
        /// </summary>
        /// <param name="node">The tree node.</param>
        /// <param name="value"><value>true</value> to make the checkbox visible on the tree node; otherwise <value>false</value>.</param>
        public static void SetIsCheckBoxVisible(this TreeNode node, bool value)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (node.TreeView == null)
            {
                throw new InvalidOperationException("The node does not belong to a tree.");
            }
            var tvi = new TVITEM
            {
                hItem     = node.Handle,
                mask      = TVIF_STATE,
                stateMask = TVIS_STATEIMAGEMASK,
                state     = (value ? node.Checked ? 2 : 1 : 0) << 12
            };
            var result = SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);

            if (result == IntPtr.Zero)
            {
                throw new ApplicationException("Error setting TreeNode state.");
            }
        }
Example #24
0
 public static extern bool SendMessage(IntPtr hWnd, int msg, int wParam, ref TVITEM tvItem);
Example #25
0
 private static extern int SendMessageTVI(IntPtr hWnd, int wMsg, int wParam, ref TVITEM tvi);
Example #26
0
 private void HideCheckBox(TreeNode node)
 {
     TVITEM tvi = new TVITEM();
     tvi.hItem = node.Handle;
     tvi.mask = TVIF_STATE;
     tvi.stateMask = TVIS_STATEIMAGEMASK;
     tvi.state = 0;
     IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));
     Marshal.StructureToPtr(tvi, lparam, false);
     SendMessage(this.tvTags.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
 }
Example #27
0
 public static extern int SendMessage(int hWnd, Int32 msg, Int32 wParam, ref TVITEM tvItem);
 private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,
                                          ref TVITEM lParam);
Example #29
0
 public static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wparam, ref TVITEM lparam);
Example #30
0
 public static extern bool WriteProcessMemory(int hProcess, int lpBaseAddress,
                                              ref TVITEM buffer, int dwSize, int lpNumberOfBytesWritten);
Example #31
0
 internal static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, ref TVITEM buffer, int dwSize, IntPtr lpNumberOfBytesWritten);
Example #32
0
 public static extern int SendMessage(int hWnd, Int32 msg, Int32 wParam, ref TVITEM tvItem);
Example #33
0
 public static extern IntPtr SendMessage(IntPtr hWnd, Int32 msg, Int32 wParam, ref TVITEM tvItem);
Example #34
0
 public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, ref TVITEM lParam);
        /// <summary>
        /// Sets a value indicating if the checkbox is visible on the tree node.
        /// </summary>
        /// <param name="node">The tree node.</param>
        /// <param name="isVisible"><value>true</value> to make the checkbox visible on the tree node; otherwise <value>false</value>.</param>
        public static void SetIsCheckBoxVisible(this TreeNode node, bool isVisible, bool applyToSubtree = false)
        {
            if (node.TreeView == null)
                throw new InvalidOperationException("The node does not belong to a tree.");
            var tvi = new TVITEM
            {
                hItem = node.Handle,
                mask = TVIF_STATE,
                stateMask = TVIS_STATEIMAGEMASK,
                state = (isVisible ? node.Checked ? 2 : 1 : 0) << 12
            };
            var result = SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
            if (result == IntPtr.Zero)
                throw new ApplicationException("Error setting TreeNode state.");

            if (applyToSubtree)
            {
                foreach (var childNode in node.GetTreeNodes())
                {
                    childNode.SetIsCheckBoxVisible(isVisible, applyToSubtree);
                }
            }
        }
Example #36
0
 public static extern int SendMessage(
     IntPtr hwnd, uint msg, uint wParam, ref TVITEM lParam);
Example #37
0
 public static extern Int32 SendMessage(int hWnd, int Msg, int wParam,
                                        TVITEM tvi);
Example #38
0
 static extern IntPtr SendMessageTVI(IntPtr hWnd, UInt32 Msg, IntPtr wParam, ref TVITEM tvi);
 private void RemoveCheckboxOnNode(TreeNode node)
 {
     TVITEM tvItem = new TVITEM();
     tvItem.hItem = node.Handle;
     tvItem.mask = TVIF_STATE;
     tvItem.stateMask = TVIS_STATEIMAGEMASK;
     tvItem.state = 0;
     IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvItem));
     try
     {
         Marshal.StructureToPtr(tvItem, lparam, false);
         SendMessage(_groupsTreeView.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
     }
     finally
     {
         Marshal.FreeHGlobal(lparam);
     }
 }
Example #40
0
 public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, ref TVITEM lParam);
Example #41
0
        public CheckBoxState GetTreeNodeState(TriStateTreeNode node)
        {
            TVITEM tvItem = new TVITEM();
            tvItem.mask = TVIF_HANDLE | TVIF_STATE;
            tvItem.hItem = node.Handle;
            tvItem.stateMask = TVIS_STATEIMAGEMASK;
            tvItem.state = 0;

            IntPtr ptr = SendMessage(this.Handle, TVM_GETITEM, 0, ref tvItem);
            if (ptr != null)
            {
                //State image index in bits 12..15
                int iState = tvItem.state >> 12;

                if (iState == (int)CheckBoxState.None)
                    return CheckBoxState.None;
                if (iState == (int)CheckBoxState.Unchecked)
                    return CheckBoxState.Unchecked;
                if (iState == (int)CheckBoxState.Checked)
                    return CheckBoxState.Checked;
                if (iState == (int)CheckBoxState.Indeterminate)
                    return CheckBoxState.Indeterminate;
            }
            return CheckBoxState.None;
        }
Example #42
0
        public static extern bool WriteProcessMemory( int hProcess, int lpBaseAddress, 
			ref TVITEM buffer, int dwSize, int lpNumberOfBytesWritten );
 private void TreeViewControl_DrawNode(object sender, DrawTreeNodeEventArgs e)
 {
     // Disable the checkbox for top level nodes such as Views and Sprocs if they have no children.
     if (e.Node.Level == 0
         && e.Node.Nodes.Count == 0)
     {
         var tvi = new TVITEM
             {
                 hItem = e.Node.Handle,
                 mask = TVIF_STATE,
                 stateMask = TVIS_STATEIMAGEMASK,
                 state = 1 << 12
             };
         var lparam = IntPtr.Zero;
         try
         {
             lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));
             Marshal.StructureToPtr(tvi, lparam, false);
             NativeMethods.SendMessage(treeView.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
         }
         finally
         {
             if (lparam != IntPtr.Zero)
             {
                 Marshal.FreeHGlobal(lparam);
             }
         }
     }
     e.DrawDefault = true;
 }
Example #44
0
        public static extern Int32 SendMessage(int hWnd, int Msg, int wParam,    
			TVITEM tvi);
Example #45
0
 public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, ref TVITEM lParam);
Example #46
0
        public void SetTreeNodeState(TriStateTreeNode node, CheckBoxState state)
        {
            if (node == null)
                return;

            TVITEM tvItem = new TVITEM();
            tvItem.mask = TVIF_HANDLE | TVIF_STATE;
            tvItem.hItem = node.Handle;
            tvItem.stateMask = TVIS_STATEIMAGEMASK;
            //State image index in bits 12..15
            tvItem.state = ((int)state) << 12;

            SendMessage(this.Handle, TVM_SETITEM, 0, ref tvItem);
        }
 private static extern UInt32 SendMessage(IntPtr hWnd, UInt32 msg,
                                          UInt32 wParam, ref TVITEM lParam);
Example #48
0
 private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, ref TVITEM lParam);
Example #49
0
 internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref TVITEM lParam);
		private static extern IntPtr SendMessage(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int msg, IntPtr wParam,
		                                         ref TVITEM item);
 /// <summary>
 /// Gets a value indicating if the checkbox is visible on the tree node.
 /// </summary>
 /// <param name="node">The tree node.</param>
 /// <returns><value>true</value> if the checkbox is visible on the tree node; otherwise <value>false</value>.</returns>
 public static bool IsCheckBoxVisible(this TreeNode node)
 {
     if (node == null)
         throw new ArgumentNullException("node");
     if (node.TreeView == null)
         throw new InvalidOperationException("The node does not belong to a tree.");
     var tvi = new TVITEM
     {
         hItem = node.Handle,
         mask = TVIF_STATE
     };
     var result = SendMessage(node.TreeView.Handle, TVM_GETITEM, node.Handle, ref tvi);
     if (result == IntPtr.Zero)
         throw new ApplicationException("Error getting TreeNode state.");
     var imageIndex = (tvi.state & TVIS_STATEIMAGEMASK) >> 12;
     return (imageIndex != 0);
 }
Example #52
0
 public static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wparam, ref TVITEM lparam);
 /// <summary>
 /// Hides the checkbox for the specified node on a TreeView control.
 /// </summary>
 private void HideCheckBox(TreeView tvw, TreeNode node)
 {
     TVITEM tvi = new TVITEM();
     if (node.Handle != null)
     {
         try
         {
             tvi.hItem = node.Handle;
             tvi.mask = TVIF_STATE;
             tvi.stateMask = TVIS_STATEIMAGEMASK;
             tvi.state = 0;
             SendMessage(tvw.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
         }
         catch (Exception ex)
         {
             Hanbo.Log.LogManager.Error(ex);
         }
     }
 }