From 585cebb26ab2abcf24b1581bdd7779e3b449a28b Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 17 Jun 2024 12:23:43 -0400 Subject: [PATCH] Added TreeView_ message macros. HTREEITEM constants, and (BREAKING CHANGE) changed TVGETITEMPARTRECTINFO to a struct and removed hidden memory allocation. Also cleaned and modernized code for TreeView. --- PInvoke/ComCtl32/CommCtrl.TreeView.cs | 2636 +++++++++++++++++++++++++++------ 1 file changed, 2182 insertions(+), 454 deletions(-) diff --git a/PInvoke/ComCtl32/CommCtrl.TreeView.cs b/PInvoke/ComCtl32/CommCtrl.TreeView.cs index bfb34ce7..b2905b7f 100644 --- a/PInvoke/ComCtl32/CommCtrl.TreeView.cs +++ b/PInvoke/ComCtl32/CommCtrl.TreeView.cs @@ -24,8 +24,8 @@ public static partial class ComCtl32 /// Corresponds to the lParam member of the second TVITEM structure for the two items being compared. /// Corresponds to the lParam member of this structure. /// - /// The callback function must return a negative value if the first item should precede the second, a positive value if the first - /// item should follow the second, or zero if the two items are equivalent. + /// The callback function must return a negative value if the first item should precede the second, a positive value if the first item + /// should follow the second, or zero if the two items are equivalent. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb773462")] public delegate int PFNTVCOMPARE(IntPtr lParam1, IntPtr lParam2, IntPtr lParamSort); @@ -35,9 +35,9 @@ public static partial class ComCtl32 public enum AsyncDrawRetFlags { /// - /// Proceed to draw the image anyway, that is, synchronously extract the image and paint. Assuming the control is on the UI - /// thread, use of this flag implies low priority UI performance, since extraction times may vary and the UI could be - /// unresponsive for an extended period of time during extraction. + /// Proceed to draw the image anyway, that is, synchronously extract the image and paint. Assuming the control is on the UI thread, + /// use of this flag implies low priority UI performance, since extraction times may vary and the UI could be unresponsive for an + /// extended period of time during extraction. /// ADRF_DRAWSYNC = 0, @@ -59,14 +59,12 @@ public static partial class ComCtl32 TVGN_CARET = 0x0009, /// - /// Retrieves the first child item of the item specified by the hitem parameter. You can use the TreeView_GetChild macro to send - /// this message. + /// Retrieves the first child item of the item specified by the hitem parameter. You can use the TreeView_GetChild macro to send this message. /// TVGN_CHILD = 0x0004, /// - /// Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to send - /// this message. + /// Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to send this message. /// TVGN_DROPHILITE = 0x0008, @@ -76,8 +74,8 @@ public static partial class ComCtl32 TVGN_FIRSTVISIBLE = 0x0005, /// - /// Version 4.71. Retrieves the last expanded item in the tree. This does not retrieve the last item visible in the tree-view - /// window. You can use the TreeView_GetLastVisible macro to send this message. + /// Version 4.71. Retrieves the last expanded item in the tree. This does not retrieve the last item visible in the tree-view window. + /// You can use the TreeView_GetLastVisible macro to send this message. /// TVGN_LASTVISIBLE = 0x000A, @@ -102,8 +100,8 @@ public static partial class ComCtl32 TVGN_PREVIOUS = 0x0002, /// - /// Retrieves the first visible item that precedes the specified item. The specified item must be visible. Use the - /// TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro to send this message. + /// Retrieves the first visible item that precedes the specified item. The specified item must be visible. Use the TVM_GETITEMRECT + /// message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro to send this message. /// TVGN_PREVIOUSVISIBLE = 0x0007, @@ -113,8 +111,8 @@ public static partial class ComCtl32 TVGN_ROOT = 0x0000, /// - /// When a single item is selected, ensures that the treeview does not expand the children of that item. This is valid only if - /// used with the TVGN_CARET flag. + /// When a single item is selected, ensures that the treeview does not expand the children of that item. This is valid only if used + /// with the TVGN_CARET flag. /// TVSI_NOSINGLEEXPAND = 0x8000 } @@ -216,8 +214,8 @@ public static partial class ComCtl32 TVIF_CHILDREN = 0x0040, /// - /// The tree-view control will retain the supplied information and will not request it again. This flag is valid only when - /// processing the TVN_GETDISPINFO notification. + /// The tree-view control will retain the supplied information and will not request it again. This flag is valid only when processing + /// the TVN_GETDISPINFO notification. /// TVIF_DI_SETITEM = 0x1000, @@ -278,8 +276,8 @@ public static partial class ComCtl32 TVIS_EXPANDED = 0x0020, /// - /// The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes - /// are not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and + /// The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes are + /// not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and /// TVE_COLLAPSERESET with TVM_EXPAND will cause this state to be reset. This value applies only to parent items. /// TVIS_EXPANDEDONCE = 0x0040, @@ -324,9 +322,7 @@ public static partial class ComCtl32 TVIS_EX_HWND = 0x0004, } - /// - /// Tree View Messages - /// + /// Tree View Messages [PInvokeData("Commctrl.h", MSDNShortId = "ff486106")] public enum TreeViewMessage { @@ -353,8 +349,8 @@ public static partial class ComCtl32 /// notification code. /// /// - /// If you delete all items in a tree-view control that has the TVS_NOSCROLL style, items subsequently added may not - /// display properly. For more information, see TreeView_DeleteAllItems. + /// If you delete all items in a tree-view control that has the TVS_NOSCROLL style, items subsequently added may not display + /// properly. For more information, see TreeView_DeleteAllItems. /// /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-deleteitem @@ -362,8 +358,8 @@ public static partial class ComCtl32 TVM_DELETEITEM = TV_FIRST + 1, /// - /// The TVM_EXPAND message expands or collapses the list of child items associated with the specified parent item, if any. - /// You can send this message explicitly or by using the TreeView_Expand macro. + /// The TVM_EXPAND message expands or collapses the list of child items associated with the specified parent item, if any. You + /// can send this message explicitly or by using the TreeView_Expand macro. /// Parameters /// wParam /// Action flag. This parameter can be one or more of the following values: @@ -379,8 +375,8 @@ public static partial class ComCtl32 /// /// TVE_COLLAPSERESET /// - /// Collapses the list and removes the child items. The TVIS_EXPANDEDONCE state flag is reset. This flag must be used with - /// the TVE_COLLAPSE flag. + /// Collapses the list and removes the child items. The TVIS_EXPANDEDONCE state flag is reset. This flag must be used with the + /// TVE_COLLAPSE flag. /// /// /// @@ -406,16 +402,16 @@ public static partial class ComCtl32 /// /// /// - /// Expanding a node that is already expanded is considered a successful operation and SendMessage returns a nonzero - /// value. Collapsing a node returns zero if the node is already collapsed; otherwise it returns nonzero. Attempting to expand or - /// collapse a node that has no children is considered a failure and SendMessage returns zero. + /// Expanding a node that is already expanded is considered a successful operation and SendMessage returns a nonzero value. + /// Collapsing a node returns zero if the node is already collapsed; otherwise it returns nonzero. Attempting to expand or collapse a + /// node that has no children is considered a failure and SendMessage returns zero. /// /// /// When an item is first expanded by a TVM_EXPAND message, the action generates TVN_ITEMEXPANDING and TVN_ITEMEXPANDED - /// notification codes and the item's TVIS_EXPANDEDONCE state flag is set. As long as this state flag remains set, - /// subsequent TVM_EXPAND messages do not generate TVN_ITEMEXPANDING or TVN_ITEMEXPANDED notifications. To reset the - /// TVIS_EXPANDEDONCE state flag, you must send a TVM_EXPAND message with the TVE_COLLAPSE and TVE_COLLAPSERESET - /// flags set. Attempting to explicitly set TVIS_EXPANDEDONCE will result in unpredictable behavior. + /// notification codes and the item's TVIS_EXPANDEDONCE state flag is set. As long as this state flag remains set, subsequent + /// TVM_EXPAND messages do not generate TVN_ITEMEXPANDING or TVN_ITEMEXPANDED notifications. To reset the + /// TVIS_EXPANDEDONCE state flag, you must send a TVM_EXPAND message with the TVE_COLLAPSE and TVE_COLLAPSERESET flags + /// set. Attempting to explicitly set TVIS_EXPANDEDONCE will result in unpredictable behavior. /// /// /// The expand operation may fail if the owner of the treeview control denies the operation in response to a TVN_ITEMEXPANDING notification. @@ -437,10 +433,9 @@ public static partial class ComCtl32 /// /// lParam /// - /// Pointer to a RECT structure that, when sending the message, contains the handle of the item to retrieve the rectangle - /// for. See the example below for more information on how to place the item handle in this parameter. After returning from the - /// message, this parameter contains the bounding rectangle. The coordinates are relative to the upper-left corner of the - /// tree-view control. + /// Pointer to a RECT structure that, when sending the message, contains the handle of the item to retrieve the rectangle for. + /// See the example below for more information on how to place the item handle in this parameter. After returning from the message, + /// this parameter contains the bounding rectangle. The coordinates are relative to the upper-left corner of the tree-view control. /// /// Returns /// @@ -450,8 +445,8 @@ public static partial class ComCtl32 /// /// /// - /// When sending this message, the lParam parameter contains the handle of the item that the rectangle is being retrieved for. - /// The handle is placed in lParam as shown in the following example: + /// When sending this message, the lParam parameter contains the handle of the item that the rectangle is being retrieved for. The + /// handle is placed in lParam as shown in the following example: /// /// /// RECT rc; *(HTREEITEM*)&rc = hTreeItem; SendMessage(hwndTreeView, TVM_GETITEMRECT, FALSE, (LPARAM)&rc); @@ -497,13 +492,13 @@ public static partial class ComCtl32 TVM_GETINDENT = TV_FIRST + 6, /// - /// Sets the width of indentation for a tree-view control and redraws the control to reflect the new width. You can send this - /// message explicitly or by using the TreeView_SetIndent macro. + /// Sets the width of indentation for a tree-view control and redraws the control to reflect the new width. You can send this message + /// explicitly or by using the TreeView_SetIndent macro. /// Parameters /// wParam /// - /// Width, in pixels, of the indentation. If this parameter is less than the system-defined minimum width, the new width is set - /// to the system-defined minimum. + /// Width, in pixels, of the indentation. If this parameter is less than the system-defined minimum width, the new width is set to + /// the system-defined minimum. /// /// lParam /// Must be zero. @@ -511,17 +506,17 @@ public static partial class ComCtl32 /// No return value. /// /// - /// The system-defined minimum indent value is typically five pixels, but it is not fixed. To retrieve the exact value of the - /// minimum indent on a particular system, send a TVM_SETINDENT message with wParam set to zero. Then send a - /// TVM_GETINDENT message to retrieve the minimum indent value. + /// The system-defined minimum indent value is typically five pixels, but it is not fixed. To retrieve the exact value of the minimum + /// indent on a particular system, send a TVM_SETINDENT message with wParam set to zero. Then send a TVM_GETINDENT + /// message to retrieve the minimum indent value. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-setindent [MsgParams(typeof(int), null, LResultType = null)] TVM_SETINDENT = TV_FIRST + 7, /// - /// Retrieves the handle to the normal or state image list associated with a tree-view control. You can send this message - /// explicitly or by using the TreeView_GetImageList macro. + /// Retrieves the handle to the normal or state image list associated with a tree-view control. You can send this message explicitly + /// or by using the TreeView_GetImageList macro. /// Parameters /// wParam /// Type of image list to retrieve. This parameter can be one of the following values: @@ -539,8 +534,8 @@ public static partial class ComCtl32 /// /// TVSIL_STATE /// - /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is - /// displayed to the left of an item's selected or nonselected image. + /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed + /// to the left of an item's selected or nonselected image. /// /// /// @@ -573,29 +568,27 @@ public static partial class ComCtl32 /// /// TVSIL_STATE /// - /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is - /// displayed to the left of an item's selected or nonselected image. + /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed + /// to the left of an item's selected or nonselected image. /// /// /// /// lParam - /// - /// Handle to the image list. If lParam is NULL, the message removes the specified image list from the tree-view control. - /// + /// Handle to the image list. If lParam is NULL, the message removes the specified image list from the tree-view control. /// Returns /// Returns the handle to the previous image list, if any, or NULL otherwise. /// /// - /// The tree-view control will not destroy the image list specified with this message. Your application must destroy the image - /// list when it is no longer needed. + /// The tree-view control will not destroy the image list specified with this message. Your application must destroy the image list + /// when it is no longer needed. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-setimagelist [MsgParams(typeof(TreeViewSetImageListType), typeof(HIMAGELIST), LResultType = typeof(HIMAGELIST))] TVM_SETIMAGELIST = TV_FIRST + 9, /// - /// Retrieves the tree-view item that bears the specified relationship to a specified item. You can send this message explicitly, - /// by using the TreeView_GetNextItem macro. + /// Retrieves the tree-view item that bears the specified relationship to a specified item. You can send this message explicitly, by + /// using the TreeView_GetNextItem macro. /// Parameters /// wParam /// Flag specifying the item to retrieve. This parameter can be one of the following values: @@ -618,22 +611,22 @@ public static partial class ComCtl32 /// /// TVGN_DROPHILITE /// - /// Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to - /// send this message. + /// Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to send + /// this message. /// /// /// /// TVGN_FIRSTVISIBLE /// - /// Retrieves the first item that is visible in the tree-view window. You can use the TreeView_GetFirstVisible macro to - /// send this message. + /// Retrieves the first item that is visible in the tree-view window. You can use the TreeView_GetFirstVisible macro to send + /// this message. /// /// /// /// TVGN_LASTVISIBLE /// - /// Version 4.71. Retrieves the last expanded item in the tree. This does not retrieve the last item visible in the tree-view - /// window. You can use the TreeView_GetLastVisible macro to send this message. + /// Version 4.71. Retrieves the last expanded item in the tree. This does not retrieve the last item visible in the tree-view window. + /// You can use the TreeView_GetLastVisible macro to send this message. /// /// /// @@ -643,16 +636,16 @@ public static partial class ComCtl32 /// /// TVGN_NEXTSELECTED /// - /// Windows Vista and later. Retrieves the next selected item. You can use the TreeView_GetNextSelected macro to - /// send this message. + /// Windows Vista and later. Retrieves the next selected item. You can use the TreeView_GetNextSelected macro to send + /// this message. /// /// /// /// TVGN_NEXTVISIBLE /// /// Retrieves the next visible item that follows the specified item. The specified item must be visible. Use the - /// TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetNextVisible macro - /// to send this message. + /// TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetNextVisible macro to + /// send this message. /// /// /// @@ -667,8 +660,8 @@ public static partial class ComCtl32 /// TVGN_PREVIOUSVISIBLE /// /// Retrieves the first visible item that precedes the specified item. The specified item must be visible. Use the - /// TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro - /// to send this message. + /// TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro to + /// send this message. /// /// /// @@ -682,8 +675,8 @@ public static partial class ComCtl32 /// Handle to an item. /// Returns /// - /// Returns the handle to the item if successful. For most cases, the message returns a NULL value to indicate an error. - /// See the Remarks section for details. + /// Returns the handle to the item if successful. For most cases, the message returns a NULL value to indicate an error. See + /// the Remarks section for details. /// /// /// @@ -736,8 +729,8 @@ public static partial class ComCtl32 TVM_GETNEXTITEM = TV_FIRST + 10, /// - /// Selects the specified tree-view item, scrolls the item into view, or redraws the item in the style used to indicate the - /// target of a drag-and-drop operation. You can send this message explicitly or by using the TreeView_Select, + /// Selects the specified tree-view item, scrolls the item into view, or redraws the item in the style used to indicate the target of + /// a drag-and-drop operation. You can send this message explicitly or by using the TreeView_Select, /// TreeView_SelectItem, or TreeView_SelectDropTarget macro. /// Parameters /// wParam @@ -750,8 +743,8 @@ public static partial class ComCtl32 /// /// TVGN_CARET /// - /// Sets the selection to the specified item. The tree-view control's parent window receives the TVN_SELCHANGING and - /// TVN_SELCHANGED notification codes. + /// Sets the selection to the specified item. The tree-view control's parent window receives the TVN_SELCHANGING and TVN_SELCHANGED + /// notification codes. /// /// /// @@ -761,16 +754,16 @@ public static partial class ComCtl32 /// /// TVGN_FIRSTVISIBLE /// - /// Ensures that the specified item is visible, and, if possible, displays it at the top of the control's window. Tree-view - /// controls display as many items as will fit in the window. If the specified item is near the bottom of the control's hierarchy - /// of items, it might not become the first visible item, depending on how many items fit in the window. + /// Ensures that the specified item is visible, and, if possible, displays it at the top of the control's window. Tree-view controls + /// display as many items as will fit in the window. If the specified item is near the bottom of the control's hierarchy of items, it + /// might not become the first visible item, depending on how many items fit in the window. /// /// /// /// TVSI_NOSINGLEEXPAND /// - /// When a single item is selected, ensures that the treeview does not expand the children of that item. This is valid only if - /// used with the TVGN_CARET flag. + /// When a single item is selected, ensures that the treeview does not expand the children of that item. This is valid only if used + /// with the TVGN_CARET flag. /// /// /// @@ -796,8 +789,8 @@ public static partial class ComCtl32 TVM_SELECTITEM = TV_FIRST + 11, /// - /// Retrieves the handle to the edit control being used to edit a tree-view item's text. You can send this message explicitly or - /// by using the TreeView_GetEditControl macro. + /// Retrieves the handle to the edit control being used to edit a tree-view item's text. You can send this message explicitly or by + /// using the TreeView_GetEditControl macro. /// Parameters /// wParam /// Must be zero. @@ -812,9 +805,9 @@ public static partial class ComCtl32 /// control sends its parent window an TVN_BEGINLABELEDIT notification code. /// /// - /// To customize label editing, implement a handler for TVN_BEGINLABELEDIT and have it send a TVM_GETEDITCONTROL message - /// to the tree-view control. If a label is being edited, the return value will be a handle to the edit control. Use this handle - /// to customize the edit control by sending the usual EM_XXX messages. + /// To customize label editing, implement a handler for TVN_BEGINLABELEDIT and have it send a TVM_GETEDITCONTROL message to + /// the tree-view control. If a label is being edited, the return value will be a handle to the edit control. Use this handle to + /// customize the edit control by sending the usual EM_XXX messages. /// /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-geteditcontrol @@ -834,12 +827,12 @@ public static partial class ComCtl32 /// /// /// - /// The number of items that can be fully visible may be greater than the number of items in the control. The control calculates - /// this value by dividing the height of the client window by the height of an item. + /// The number of items that can be fully visible may be greater than the number of items in the control. The control calculates this + /// value by dividing the height of the client window by the height of an item. /// /// - /// Note that the return value is the number of items that can be fully visible. If you can see all of 20 items and part of one - /// more item, the return value is 20. + /// Note that the return value is the number of items that can be fully visible. If you can see all of 20 items and part of one more + /// item, the return value is 20. /// /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-getvisiblecount @@ -855,23 +848,21 @@ public static partial class ComCtl32 /// lParam /// /// Pointer to a TVHITTESTINFO structure. When the message is sent, the pt member specifies the coordinates of the - /// point to test. When the message returns, the hItem member is the handle to the item at the specified point or - /// NULL if no item occupies the point. Also, when the message returns, the flags member is a hit test value that - /// indicates the location of the specified point. For a list of hit test values, see the description of the TVHITTESTINFO structure. + /// point to test. When the message returns, the hItem member is the handle to the item at the specified point or NULL + /// if no item occupies the point. Also, when the message returns, the flags member is a hit test value that indicates the + /// location of the specified point. For a list of hit test values, see the description of the TVHITTESTINFO structure. /// /// Returns - /// - /// Returns the handle to the tree-view item that occupies the specified point, or NULL if no item occupies the point. - /// + /// Returns the handle to the tree-view item that occupies the specified point, or NULL if no item occupies the point. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-hittest [MsgParams(null, typeof(TVHITTESTINFO), LResultType = typeof(HTREEITEM))] TVM_HITTEST = TV_FIRST + 17, /// - /// Creates a dragging bitmap for the specified item in a tree-view control. The message also creates an image list for the - /// bitmap and adds the bitmap to the image list. An application can display the image when dragging the item by using the image - /// list functions. You can send this message explicitly or by using the TreeView_CreateDragImage macro. + /// Creates a dragging bitmap for the specified item in a tree-view control. The message also creates an image list for the bitmap + /// and adds the bitmap to the image list. An application can display the image when dragging the item by using the image list + /// functions. You can send this message explicitly or by using the TreeView_CreateDragImage macro. /// Parameters /// wParam /// Must be zero. @@ -892,8 +883,8 @@ public static partial class ComCtl32 TVM_CREATEDRAGIMAGE = TV_FIRST + 18, /// - /// Sorts the child items of the specified parent item in a tree-view control. You can send this message explicitly or by using - /// the TreeView_SortChildren macro. + /// Sorts the child items of the specified parent item in a tree-view control. You can send this message explicitly or by using the + /// TreeView_SortChildren macro. /// Parameters /// wParam /// @@ -928,8 +919,8 @@ public static partial class ComCtl32 /// /// /// - /// If the TVM_ENSUREVISIBLE message expands the parent item, the parent window receives the TVN_ITEMEXPANDING and - /// TVN_ITEMEXPANDED notification codes. + /// If the TVM_ENSUREVISIBLE message expands the parent item, the parent window receives the TVN_ITEMEXPANDING and TVN_ITEMEXPANDED + /// notification codes. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-ensurevisible [MsgParams(null, typeof(HTREEITEM), LResultType = typeof(BOOL))] @@ -944,8 +935,8 @@ public static partial class ComCtl32 /// lParam /// /// Pointer to a TVSORTCB structure. The lpfnCompare member is the address of the application-defined callback - /// function, which is called during the sort operation each time the relative order of two list items needs to be compared. For - /// more information about the callback function, see the description of TVSORTCB. + /// function, which is called during the sort operation each time the relative order of two list items needs to be compared. For more + /// information about the callback function, see the description of TVSORTCB. /// /// Returns /// Returns TRUE if successful, or FALSE otherwise. @@ -960,8 +951,8 @@ public static partial class ComCtl32 /// Parameters /// wParam /// - /// Variable that indicates whether the editing is canceled without being saved to the label. If this parameter is TRUE, - /// the system cancels editing without saving the changes. Otherwise, the system saves the changes to the label. + /// Variable that indicates whether the editing is canceled without being saved to the label. If this parameter is TRUE, the + /// system cancels editing without saving the changes. Otherwise, the system saves the changes to the label. /// /// lParam /// Must be zero. @@ -983,8 +974,7 @@ public static partial class ComCtl32 /// Must be zero. /// Returns /// - /// Returns the handle to tooltip control previously set for the tree-view control, or NULL if tooltips were not - /// previously used. + /// Returns the handle to tooltip control previously set for the tree-view control, or NULL if tooltips were not previously used. /// /// /// @@ -996,8 +986,8 @@ public static partial class ComCtl32 TVM_SETTOOLTIPS = TV_FIRST + 24, /// - /// Retrieves the handle to the child tooltip control used by a tree-view control. You can send this message explicitly or by - /// using the TreeView_GetToolTips macro. + /// Retrieves the handle to the child tooltip control used by a tree-view control. You can send this message explicitly or by using + /// the TreeView_GetToolTips macro. /// Parameters /// wParam /// Must be zero. @@ -1007,8 +997,8 @@ public static partial class ComCtl32 /// Returns the handle to the child tooltip control, or NULL if the control is not using tooltips. /// /// - /// When created, tree-view controls automatically create a child tooltip control. To cause a tree-view control not to use - /// tooltips, create the control with the TVS_NOTOOLTIPS style. + /// When created, tree-view controls automatically create a child tooltip control. To cause a tree-view control not to use tooltips, + /// create the control with the TVS_NOTOOLTIPS style. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-gettooltips [MsgParams(null, null, LResultType = typeof(HWND))] @@ -1020,35 +1010,34 @@ public static partial class ComCtl32 /// Parameters /// wParam /// - /// BOOL value that specifies if the insertion mark is placed before or after the specified item. If this argument is - /// nonzero, the insertion mark will be placed after the item. If this argument is zero, the insertion mark will be placed before - /// the item. + /// BOOL value that specifies if the insertion mark is placed before or after the specified item. If this argument is nonzero, + /// the insertion mark will be placed after the item. If this argument is zero, the insertion mark will be placed before the item. /// /// lParam /// - /// HTREEITEM that specifies at which item the insertion mark will be placed. If this argument is NULL, the - /// insertion mark is removed. + /// HTREEITEM that specifies at which item the insertion mark will be placed. If this argument is NULL, the insertion + /// mark is removed. /// /// Returns /// Returns nonzero if successful, or zero otherwise. /// /// - /// In some circumstances, the insert mark can appear in two places after a node is expanded. If you are using insertion marks, - /// it is recommended that you force a refresh of the control after expanding a node. + /// In some circumstances, the insert mark can appear in two places after a node is expanded. If you are using insertion marks, it is + /// recommended that you force a refresh of the control after expanding a node. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-setinsertmark [MsgParams(typeof(BOOL), typeof(HTREEITEM), LResultType = typeof(BOOL))] TVM_SETINSERTMARK = TV_FIRST + 26, /// - /// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the - /// control at run time rather than having to re-create the control. You can send this message explicitly or use the + /// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the control + /// at run time rather than having to re-create the control. You can send this message explicitly or use the /// TreeView_SetUnicodeFormat macro. /// Parameters /// wParam /// - /// Determines the character set that is used by the control. If this value is nonzero, the control will use Unicode characters. - /// If this value is zero, the control will use ANSI characters. + /// Determines the character set that is used by the control. If this value is nonzero, the control will use Unicode characters. If + /// this value is zero, the control will use ANSI characters. /// /// lParam /// Must be zero. @@ -1070,8 +1059,8 @@ public static partial class ComCtl32 /// Must be zero. /// Returns /// - /// Returns the Unicode format flag for the control. If this value is nonzero, the control is using Unicode characters. If this - /// value is zero, the control is using ANSI characters. + /// Returns the Unicode format flag for the control. If this value is nonzero, the control is using Unicode characters. If this value + /// is zero, the control is using ANSI characters. /// /// /// See the remarks for CCM_GETUNICODEFORMAT for a discussion of this message. @@ -1084,9 +1073,9 @@ public static partial class ComCtl32 /// Parameters /// wParam /// - /// New height of every item in the tree view, in pixels. Heights less than 1 will be set to 1. If this argument is not even and - /// the tree-view control does not have the TVS_NONEVENHEIGHT style, this value will be rounded down to the nearest even - /// value. If this argument is -1, the control will revert to using its default item height. + /// New height of every item in the tree view, in pixels. Heights less than 1 will be set to 1. If this argument is not even and the + /// tree-view control does not have the TVS_NONEVENHEIGHT style, this value will be rounded down to the nearest even value. If + /// this argument is -1, the control will revert to using its default item height. /// /// lParam /// Must be zero. @@ -1094,8 +1083,8 @@ public static partial class ComCtl32 /// Returns the previous height of the items, in pixels. /// /// - /// The tree-view control uses this value for the height of all items. To modify the height of individual items, see the - /// description of the iIntegral member of the TVITEMEX structure. + /// The tree-view control uses this value for the height of all items. To modify the height of individual items, see the description + /// of the iIntegral member of the TVITEMEX structure. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-setitemheight [MsgParams(typeof(int), null, LResultType = typeof(int))] @@ -1123,8 +1112,8 @@ public static partial class ComCtl32 /// Must be zero. /// lParam /// - /// COLORREF value that contains the new background color. If this value is -1, the control will revert to using the - /// system color for the background color. + /// COLORREF value that contains the new background color. If this value is -1, the control will revert to using the system + /// color for the background color. /// /// Returns /// @@ -1143,13 +1132,13 @@ public static partial class ComCtl32 /// Must be zero. /// lParam /// - /// COLORREF value that contains the new text color. If this argument is -1, the control will revert to using the system - /// color for the text color. + /// COLORREF value that contains the new text color. If this argument is -1, the control will revert to using the system color + /// for the text color. /// /// Returns /// - /// Returns a COLORREF value that represents the previous text color. If this value is -1, the control was using the - /// system color for the text color. + /// Returns a COLORREF value that represents the previous text color. If this value is -1, the control was using the system + /// color for the text color. /// /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-settextcolor @@ -1204,8 +1193,8 @@ public static partial class ComCtl32 /// Returns the previous maximum scroll time, in milliseconds. /// /// - /// The maximum scroll time is the longest amount of time that a scroll operation can take. Scrolling will be adjusted so that - /// the scroll will take place within the maximum scroll time. A scroll operation may take less time than the maximum. + /// The maximum scroll time is the longest amount of time that a scroll operation can take. Scrolling will be adjusted so that the + /// scroll will take place within the maximum scroll time. A scroll operation may take less time than the maximum. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-setscrolltime [MsgParams(typeof(uint), null, LResultType = typeof(uint))] @@ -1223,8 +1212,8 @@ public static partial class ComCtl32 /// Returns the maximum scroll time, in milliseconds. /// /// - /// The maximum scroll time is the longest amount of time that a scroll operation can take. The scrolling will be adjusted so - /// that the scroll will take place within the maximum scroll time. A scroll operation may take less time than the maximum. + /// The maximum scroll time is the longest amount of time that a scroll operation can take. The scrolling will be adjusted so that + /// the scroll will take place within the maximum scroll time. A scroll operation may take less time than the maximum. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-getscrolltime [MsgParams(null, null, LResultType = typeof(uint))] @@ -1285,21 +1274,21 @@ public static partial class ComCtl32 /// /// lParam /// - /// The LOWORD is a SHORT that specifies the size of the left border, in pixels. The HIWORD is a - /// SHORT that specifies the size of the top border, in pixels. + /// The LOWORD is a SHORT that specifies the size of the left border, in pixels. The HIWORD is a SHORT + /// that specifies the size of the top border, in pixels. /// /// Returns /// - /// Returns a LONG value that contains the previous border size, in pixels. The LOWORD contains the previous size - /// of the horizontal border, and the HIWORD contains the previous size of the vertical border. + /// Returns a LONG value that contains the previous border size, in pixels. The LOWORD contains the previous size of + /// the horizontal border, and the HIWORD contains the previous size of the vertical border. /// /// /// /// Security Warning: Using this message might compromise the security of your program. /// The item border is set just for spacing purposes. A successful setting triggers a recalculation of the scroll bars. /// - /// This message may not be supported in future versions of Comctl32.dll. Also, this message is not defined in commctrl.h. Add - /// the following definitions to the source files of your application to use the message: + /// This message may not be supported in future versions of Comctl32.dll. Also, this message is not defined in commctrl.h. Add the + /// following definitions to the source files of your application to use the message: /// /// /// #define TVM_SETBORDER (TV_FIRST + 35) #define TVSBF_XBORDER 0x00000001 #define TVSBF_YBORDER 0x00000002 @@ -1319,15 +1308,16 @@ public static partial class ComCtl32 /// Mask used to specify the states to query for. It is equivalent to the stateMask member of TVITEMEX. /// Returns /// - /// Returns a UINT value with the appropriate state bits set to TRUE. Only those bits that are specified by lParam - /// and that are TRUE will be set. This value is equivalent to the state member of TVITEMEX. + /// Returns a UINT value with the appropriate state bits set to TRUE. Only those bits that are specified by lParam and + /// that are TRUE will be set. This value is equivalent to the state member of TVITEMEX. /// /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-getitemstate [MsgParams(typeof(HTREEITEM), typeof(TreeViewItemStates), LResultType = typeof(TreeViewItemStates))] TVM_GETITEMSTATE = TV_FIRST + 39, - /// The TVM_SETLINECOLOR message sets the current line color. + /// + /// The TVM_SETLINECOLOR message sets the current line color. /// Parameters /// wParam /// Must be zero. @@ -1344,7 +1334,8 @@ public static partial class ComCtl32 [MsgParams(null, typeof(COLORREF), LResultType = typeof(COLORREF))] TVM_SETLINECOLOR = TV_FIRST + 40, - /// The TVM_GETLINECOLOR message gets the current line color. + /// + /// The TVM_GETLINECOLOR message gets the current line color. /// Parameters /// wParam /// Must be zero. @@ -1361,7 +1352,8 @@ public static partial class ComCtl32 [MsgParams(null, null, LResultType = typeof(COLORREF))] TVM_GETLINECOLOR = TV_FIRST + 41, - /// Maps an accessibility ID to an HTREEITEM. + /// + /// Maps an accessibility ID to an HTREEITEM. /// Parameters /// wParam /// **UINT** that contains the accessibility ID to map to an **HTREEITEM**. @@ -1384,7 +1376,8 @@ public static partial class ComCtl32 [MsgParams(typeof(uint), null, LResultType = typeof(HTREEITEM))] TVM_MAPACCIDTOHTREEITEM = TV_FIRST + 42, - /// Maps an HTREEITEM to an accessibility ID. + /// + /// Maps an HTREEITEM to an accessibility ID. /// Parameters /// wParam /// **HTREEITEM** that is mapped to an accessibility ID. @@ -1407,7 +1400,8 @@ public static partial class ComCtl32 [MsgParams(typeof(HTREEITEM), null, LResultType = typeof(uint))] TVM_MAPHTREEITEMTOACCID = TV_FIRST + 43, - /// Informs the tree-view control to set extended styles. Send this message or use the macro TreeView_SetExtendedStyle. + /// + /// Informs the tree-view control to set extended styles. Send this message or use the macro TreeView_SetExtendedStyle. /// Parameters /// wParam /// Mask used to select the styles to be set. @@ -1417,8 +1411,8 @@ public static partial class ComCtl32 /// If this message succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// - /// The extended styles for a tree-view control have nothing to do with the extended styles used with function - /// CreateWindowEx or function SetWindowLong. + /// The extended styles for a tree-view control have nothing to do with the extended styles used with function CreateWindowEx + /// or function SetWindowLong. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-setextendedstyle [MsgParams(typeof(TreeViewStyleEx), typeof(TreeViewStyleEx), LResultType = typeof(HRESULT))] @@ -1436,8 +1430,8 @@ public static partial class ComCtl32 /// Returns the value of extended style.For more information on styles, see Tree-View Control Extended Styles. /// /// - /// The extended styles for a tree-view control have nothing to do with the extended styles used with function - /// CreateWindowEx or function SetWindowLong. + /// The extended styles for a tree-view control have nothing to do with the extended styles used with function CreateWindowEx + /// or function SetWindowLong. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-getextendedstyle [MsgParams(null, null, LResultType = typeof(TreeViewStyleEx))] @@ -1571,10 +1565,10 @@ public static partial class ComCtl32 /// /// /// - /// Security Warning: Using this message incorrectly might compromise the security of your program. You must allocate a - /// large enough buffer to hold the string. First call the message passing NULL in lParam. This returns the number of - /// characters, excluding NULL, that are required. Then call the message a second time to retrieve the string. You should - /// review Security Considerations: Microsoft Windows Controls before continuing. + /// Security Warning: Using this message incorrectly might compromise the security of your program. You must allocate a large + /// enough buffer to hold the string. First call the message passing NULL in lParam. This returns the number of characters, + /// excluding NULL, that are required. Then call the message a second time to retrieve the string. You should review Security + /// Considerations: Microsoft Windows Controls before continuing. /// /// If the tree-view control is not in incremental search mode, the return value is zero. /// @@ -1583,9 +1577,9 @@ public static partial class ComCtl32 TVM_GETISEARCHSTRING = TV_FIRST + 64, /// - /// Begins in-place editing of the specified item's text, replacing the text of the item with a single-line edit control - /// containing the text. This message implicitly selects and focuses the specified item. You can send this message explicitly or - /// by using the TreeView_EditLabel macro. + /// Begins in-place editing of the specified item's text, replacing the text of the item with a single-line edit control containing + /// the text. This message implicitly selects and focuses the specified item. You can send this message explicitly or by using the + /// TreeView_EditLabel macro. /// Parameters /// wParam /// Must be zero. @@ -1597,8 +1591,8 @@ public static partial class ComCtl32 /// /// This message sends a TVN_BEGINLABELEDIT notification code to the parent of the tree-view control. /// - /// When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid. You can subclass - /// the edit control, but do not destroy it. + /// When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid. You can subclass the + /// edit control, but do not destroy it. /// /// /// The control must have the focus before you send this message to the control. Focus can be set using the SetFocus function. @@ -1624,8 +1618,8 @@ public static partial class ComCtl32 /// Returns zero. /// /// - /// Most applications do not use this message. Infotips are shown automatically. For more information, see Using Tree-view - /// Infotips in the About Tree-View Controls overview. + /// Most applications do not use this message. Infotips are shown automatically. For more information, see Using Tree-view Infotips + /// in the About Tree-View Controls overview. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvm-showinfotip [MsgParams(null, typeof(HTREEITEM), LResultType = typeof(int))] @@ -1642,8 +1636,8 @@ public static partial class ComCtl32 { /// /// - /// Sent by a tree-view control to its parent when the drawing of a icon or overlay has failed. This notification code is sent in - /// the form of a WM_NOTIFY message. + /// Sent by a tree-view control to its parent when the drawing of a icon or overlay has failed. This notification code is sent in the + /// form of a WM_NOTIFY message. /// /// /// TVN_ASYNCDRAW pnmTVAsynchDraw = (NMTVASYNCDRAW *) lParam; @@ -1660,30 +1654,29 @@ public static partial class ComCtl32 /// LVN_ASYNCDRAWN flag and its corresponding style. /// /// - /// This control does not draw asynchronously. Asynchronous is used in the context that the tree-view control does not - /// synchronously extract an image if it is not available. (For instance, the image may not be available if the tree-view control - /// uses a sparse image list, since the image may be unloaded.) Instead, when an image is not available, the control - /// synchronously asks the parent what action to take by sending the parent an TVN_ASYNCDRAW notification with a - /// NMTVASYNCDRAW structure. The hr member of this structure describes the reason the control's draw failed. An - /// hr result of E_PENDING means the image is not present at all (the image needs to be extracted). Success indicates that - /// the image is present but not at the required image quality. + /// This control does not draw asynchronously. Asynchronous is used in the context that the tree-view control does not synchronously + /// extract an image if it is not available. (For instance, the image may not be available if the tree-view control uses a sparse + /// image list, since the image may be unloaded.) Instead, when an image is not available, the control synchronously asks the parent + /// what action to take by sending the parent an TVN_ASYNCDRAW notification with a NMTVASYNCDRAW structure. The hr + /// member of this structure describes the reason the control's draw failed. An hr result of E_PENDING means the image is not + /// present at all (the image needs to be extracted). Success indicates that the image is present but not at the required image quality. /// /// - /// The parent sets the dwRetFlags member of the structure to inform the control how to proceed. For instance, the parent - /// may return another image, in the iRetImageIndex member, for the control to draw. In this case, the parent sets the + /// The parent sets the dwRetFlags member of the structure to inform the control how to proceed. For instance, the parent may + /// return another image, in the iRetImageIndex member, for the control to draw. In this case, the parent sets the /// dwRetFlags member to ADRF_DRAWIMAGE. If the control finds the returned image has not been extracted, yet another /// TVN_ASYNCDRAW notification may be sent by the control. /// /// /// If an image is not available, the idea behind asynchronous is to allow the parent do the extraction in the background so that /// extraction does not block the UI thread, that is, the thread the control is on. The parent may return ADRF_DRAWNOTHING to the - /// control, then launch a background thread to extract the icon. Once extracted, the parent may set the icon in the treeview - /// control with macro TreeView_SetItem. This causes tree-view to invalidate the item and eventually repaint it with the - /// extracted image in the image list. + /// control, then launch a background thread to extract the icon. Once extracted, the parent may set the icon in the treeview control + /// with macro TreeView_SetItem. This causes tree-view to invalidate the item and eventually repaint it with the extracted + /// image in the image list. /// /// - /// The following code example, to be used as part of a larger program, shows how a parent may process two possible return codes - /// in this notification by a control, and decide what action the control should take. Setting dwRetFlags is not shown. + /// The following code example, to be used as part of a larger program, shows how a parent may process two possible return codes in + /// this notification by a control, and decide what action the control should take. Setting dwRetFlags is not shown. /// /// /// case TVN_ASYNCDRAW: NMTVASYNCDRAW *pnm = (NMTVASYNCDRAW *)lParam short dwDrawSuccessFlags = ShortFromResult(pnm->hr); if (dwDrawSuccessFlags & ILDRF_IMAGELOWQUALITY) { // Need to re-extract the icon } if (dwDrawSuccessFlags & ILDRF_OVERLAYLOWQUALITY) { // Need to re-extract the overlay } @@ -1695,8 +1688,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window that a drag-and-drop operation involving the left mouse button is being - /// initiated. This notification code is sent in the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window that a drag-and-drop operation involving the left mouse button is being initiated. + /// This notification code is sent in the form of a WM_NOTIFY message. /// /// /// TVN_BEGINDRAG pnmtv = (LPNMTREEVIEW) lParam @@ -1704,9 +1697,9 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid - /// information about the item being dragged in the hItem, state, and lParam members. The ptDrag - /// member specifies the current screen coordinates of the mouse. + /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid information + /// about the item being dragged in the hItem, state, and lParam members. The ptDrag member specifies the + /// current screen coordinates of the mouse. /// /// Returns /// The return value is ignored. @@ -1718,8 +1711,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window about the start of label editing for an item. This notification code is sent in - /// the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window about the start of label editing for an item. This notification code is sent in the + /// form of a WM_NOTIFY message. /// /// /// TVN_BEGINLABELEDIT ptvdi = (LPNMTVDISPINFO) lParam @@ -1727,8 +1720,8 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTVDISPINFO structure. The item member is a TVITEM structure that contains valid - /// information about the item being edited in the hItem, state, lParam, and pszText members. + /// Pointer to an NMTVDISPINFO structure. The item member is a TVITEM structure that contains valid information + /// about the item being edited in the hItem, state, lParam, and pszText members. /// /// Returns /// Returns TRUE to cancel label editing. @@ -1739,9 +1732,9 @@ public static partial class ComCtl32 /// control sends its parent window a TVN_BEGINLABELEDIT notification code. /// /// - /// To customize label editing, implement a handler for TVN_BEGINLABELEDIT and have it send a TVM_GETEDITCONTROL message - /// to the tree-view control. If a label is being edited, the return value will be a handle to the edit control. Use this handle - /// to customize the edit control by sending the usual EM_XXX messages. + /// To customize label editing, implement a handler for TVN_BEGINLABELEDIT and have it send a TVM_GETEDITCONTROL message to + /// the tree-view control. If a label is being edited, the return value will be a handle to the edit control. Use this handle to + /// customize the edit control by sending the usual EM_XXX messages. /// /// When the user cancels or completes the editing, the parent window receives a TVN_ENDLABELEDIT notification code. /// @@ -1751,8 +1744,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window about the initiation of a drag-and-drop operation involving the right mouse - /// button. This notification code is sent in the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window about the initiation of a drag-and-drop operation involving the right mouse button. + /// This notification code is sent in the form of a WM_NOTIFY message. /// /// /// TVN_BEGINRDRAG pnmtv = (LPNMTREEVIEW) lParam @@ -1760,9 +1753,9 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid - /// information in the hItem, state, and lParam members about the item to be dragged. The ptDrag - /// member specifies the current screen coordinates of the mouse. + /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid information + /// in the hItem, state, and lParam members about the item to be dragged. The ptDrag member specifies the + /// current screen coordinates of the mouse. /// /// Returns /// The return value is ignored. @@ -1789,8 +1782,8 @@ public static partial class ComCtl32 /// The return value is ignored. /// /// - /// If the lParam member of the TVITEM structure points to memory allocated by your application, you can free it - /// when you receive the TVN_DELETEITEM notification code. + /// If the lParam member of the TVITEM structure points to memory allocated by your application, you can free it when + /// you receive the TVN_DELETEITEM notification code. /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvn-deleteitem [MsgParams(null, typeof(NMTREEVIEW?), LResultType = null)] @@ -1798,8 +1791,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window about the end of label editing for an item. This notification code is sent in - /// the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window about the end of label editing for an item. This notification code is sent in the + /// form of a WM_NOTIFY message. /// /// /// TVN_ENDLABELEDIT ptvdi = (LPNMTVDISPINFO) lParam @@ -1809,8 +1802,8 @@ public static partial class ComCtl32 /// /// Pointer to an NMTVDISPINFO structure. The item member of this structure is a TVITEM structure whose /// hItem, lParam, and pszText members contain valid information about the item that was edited. If label - /// editing was canceled, the pszText member of the TVITEM structure is NULL; otherwise, pszText is - /// the address of the edited text. + /// editing was canceled, the pszText member of the TVITEM structure is NULL; otherwise, pszText is the + /// address of the edited text. /// /// Returns /// @@ -1831,8 +1824,8 @@ public static partial class ComCtl32 /// /// - /// Requests that a tree-view control's parent window provide information needed to display or sort an item. This notification - /// code is sent in the form of a WM_NOTIFY message. + /// Requests that a tree-view control's parent window provide information needed to display or sort an item. This notification code + /// is sent in the form of a WM_NOTIFY message. /// /// /// TVN_GETDISPINFO lptvdi = (LPNMTVDISPINFO) lParam @@ -1840,9 +1833,9 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTVDISPINFO structure. The item member is a TVITEM structure whose mask, - /// hItem, state, and lParam members specify the type of information required. You must fill the members of - /// the structure with the appropriate information. + /// Pointer to an NMTVDISPINFO structure. The item member is a TVITEM structure whose mask, hItem, + /// state, and lParam members specify the type of information required. You must fill the members of the structure with + /// the appropriate information. /// /// Returns /// The return value is ignored. @@ -1859,16 +1852,16 @@ public static partial class ComCtl32 /// /// /// If the iImage or iSelectedImage member of the item's TVITEM structure is the I_IMAGECALLBACK value, the - /// control sends this notification code to retrieve the index of an item's icons in the control's image list. In this case, if - /// the item is selected, the mask member of lParam will have the TVIF_SELECTEDIMAGE flag set. If the item is not - /// selected, the mask member of lParam will have the TVIF_IMAGE flag set. + /// control sends this notification code to retrieve the index of an item's icons in the control's image list. In this case, if the + /// item is selected, the mask member of lParam will have the TVIF_SELECTEDIMAGE flag set. If the item is not selected, the + /// mask member of lParam will have the TVIF_IMAGE flag set. /// /// /// /// /// If the cChildren member of the item's TVITEM structure is the I_CHILDRENCALLBACK value, the control sends this - /// notification code to retrieve a value that indicates whether the item has child items. In this case, the mask member - /// of lParam will have the TVIF_CHILDREN flag set. + /// notification code to retrieve a value that indicates whether the item has child items. In this case, the mask member of + /// lParam will have the TVIF_CHILDREN flag set. /// /// /// @@ -1879,9 +1872,8 @@ public static partial class ComCtl32 /// /// - /// Sent by a tree-view control that has the TVS_INFOTIP style. This notification code is sent when the control is - /// requesting additional text information to be displayed in a tooltip. The notification code is sent in the form of a - /// WM_NOTIFY message. + /// Sent by a tree-view control that has the TVS_INFOTIP style. This notification code is sent when the control is requesting + /// additional text information to be displayed in a tooltip. The notification code is sent in the form of a WM_NOTIFY message. /// /// /// TVN_GETINFOTIP lpGetInfoTip = (LPNMTVGETINFOTIP)lParam; @@ -1899,17 +1891,15 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window that item attributes have changed. This notification code is sent in the form of - /// a WM_NOTIFY message. + /// Notifies a tree-view control's parent window that item attributes have changed. This notification code is sent in the form of a + /// WM_NOTIFY message. /// /// /// TVN_ITEMCHANGED pnm = (NMTVITEMCHANGE *) lParam; /// /// Parameters /// lParam - /// - /// Pointer to a NMTVITEMCHANGE structure describing the item that changed. The uChanged member is set to TVIF_STATE. - /// + /// Pointer to a NMTVITEMCHANGE structure describing the item that changed. The uChanged member is set to TVIF_STATE. /// Returns /// Returns FALSE to accept the change, or TRUE to prevent the change. /// @@ -1919,8 +1909,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window that item attributes are about to change. This notification code is sent in the - /// form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window that item attributes are about to change. This notification code is sent in the form + /// of a WM_NOTIFY message. /// /// /// TVN_ITEMCHANGING pnm = (NMTVITEMCHANGE *) lParam; @@ -1948,9 +1938,9 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid - /// information about the parent item in the hItem, state, and lParam members. The action member - /// indicates whether the list expanded or collapsed. For a list of possible values, see the description of the TVM_EXPAND message. + /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid information + /// about the parent item in the hItem, state, and lParam members. The action member indicates whether + /// the list expanded or collapsed. For a list of possible values, see the description of the TVM_EXPAND message. /// /// Returns /// The return value is ignored. @@ -1970,10 +1960,9 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid - /// information about the parent item in the hItem, state, and lParam members. The action member - /// indicates whether the list is to expand or collapse. For a list of possible values, see the description of the - /// TVM_EXPAND message. + /// Pointer to an NMTREEVIEW structure. The itemNew member is a TVITEM structure that contains valid information + /// about the parent item in the hItem, state, and lParam members. The action member indicates whether + /// the list is to expand or collapse. For a list of possible values, see the description of the TVM_EXPAND message. /// /// Returns /// Returns TRUE to prevent the list from expanding or collapsing. @@ -1995,9 +1984,9 @@ public static partial class ComCtl32 /// Pointer to an NMTVKEYDOWN structure. The wVKey member specifies the virtual key code. /// Returns /// - /// If the wVKey member of lParam is a character key code, the character will be used as part of an incremental search. - /// Return nonzero to exclude the character from the incremental search, or zero to include the character in the search. For all - /// other keys, the return value is ignored. + /// If the wVKey member of lParam is a character key code, the character will be used as part of an incremental search. Return + /// nonzero to exclude the character from the incremental search, or zero to include the character in the search. For all other keys, + /// the return value is ignored. /// /// // https://docs.microsoft.com/en-us/windows/win32/controls/tvn-keydown @@ -2006,8 +1995,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window that the selection has changed from one item to another. This notification code - /// is sent in the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window that the selection has changed from one item to another. This notification code is + /// sent in the form of a WM_NOTIFY message. /// /// /// TVN_SELCHANGED pnmtv = (LPNMTREEVIEW) lParam @@ -2015,12 +2004,11 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTREEVIEW structure. The itemOld and itemNew members of the NMTREEVIEW structure - /// are TVITEM structures that contain information about the previously selected item and the newly selected item. Only - /// the mask, hItem, state, and lParam members of these structures are valid. The stateMask - /// members of the TVITEM structures specified by itemOld and itemNew are undefined on input. The - /// action member of the NMTREEVIEW structure indicates the type of action that caused the selection to change. It - /// can be one of the following values: + /// Pointer to an NMTREEVIEW structure. The itemOld and itemNew members of the NMTREEVIEW structure are + /// TVITEM structures that contain information about the previously selected item and the newly selected item. Only the + /// mask, hItem, state, and lParam members of these structures are valid. The stateMask members of + /// the TVITEM structures specified by itemOld and itemNew are undefined on input. The action member of + /// the NMTREEVIEW structure indicates the type of action that caused the selection to change. It can be one of the following values: /// /// /// @@ -2049,8 +2037,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window that the selection is about to change from one item to another. This - /// notification code is sent in the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window that the selection is about to change from one item to another. This notification + /// code is sent in the form of a WM_NOTIFY message. /// /// /// TVN_SELCHANGING pnmtv = (LPNMTREEVIEW) lParam @@ -2074,8 +2062,8 @@ public static partial class ComCtl32 /// /// - /// Notifies a tree-view control's parent window that it must update the information it maintains about an item. This - /// notification code is sent in the form of a WM_NOTIFY message. + /// Notifies a tree-view control's parent window that it must update the information it maintains about an item. This notification + /// code is sent in the form of a WM_NOTIFY message. /// /// /// TVN_SETDISPINFO lptvdi = (LPNMTVDISPINFO) lParam @@ -2083,9 +2071,8 @@ public static partial class ComCtl32 /// Parameters /// lParam /// - /// Pointer to an NMTVDISPINFO structure that describes the item being updated. The hItem member of the - /// TVITEM structure specifies the item being updated, and the mask member specifies which attributes of the item - /// are being updated. + /// Pointer to an NMTVDISPINFO structure that describes the item being updated. The hItem member of the TVITEM + /// structure specifies the item being updated, and the mask member specifies which attributes of the item are being updated. /// /// Returns /// The return value is ignored. @@ -2107,8 +2094,8 @@ public static partial class ComCtl32 /// /// - /// Sent by a tree-view control with the TVS_SINGLEEXPAND style when the user opens or closes a tree item using a single - /// click of the mouse. This notification code is sent in the form of a WM_NOTIFY message. + /// Sent by a tree-view control with the TVS_SINGLEEXPAND style when the user opens or closes a tree item using a single click + /// of the mouse. This notification code is sent in the form of a WM_NOTIFY message. /// /// /// TVN_SINGLEEXPAND lpnmtv = (LPNMTREEVIEW)lParam; @@ -2135,8 +2122,8 @@ public static partial class ComCtl32 /// /// /// - /// To skip default processing of selected and unselected items, return both TVNRET_SKIPOLD and TVNRET_SKIPNEW by combining them - /// with a logical OR. + /// To skip default processing of selected and unselected items, return both TVNRET_SKIPOLD and TVNRET_SKIPNEW by combining them with + /// a logical OR. /// /// This notification code is only sent by tree-view controls that have the TVS_SINGLEEXPAND style. /// @@ -2195,8 +2182,8 @@ public static partial class ComCtl32 TVSIL_NORMAL = 0, /// - /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is - /// displayed to the left of an item's selected or nonselected image. + /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed + /// to the left of an item's selected or nonselected image. /// TVSIL_STATE = 2 } @@ -2207,20 +2194,20 @@ public static partial class ComCtl32 public enum TreeViewStyle { /// - /// Version 4.70. Enables check boxes for items in a tree-view control. A check box is displayed only if an image is associated - /// with the item. When set to this style, the control effectively uses DrawFrameControl to create and set a state image list - /// containing two images. State image 1 is the unchecked box and state image 2 is the checked box. Setting the state image to - /// zero removes the check box altogether. For more information, see Working with state image indexes. + /// Version 4.70. Enables check boxes for items in a tree-view control. A check box is displayed only if an image is associated with + /// the item. When set to this style, the control effectively uses DrawFrameControl to create and set a state image list containing + /// two images. State image 1 is the unchecked box and state image 2 is the checked box. Setting the state image to zero removes the + /// check box altogether. For more information, see Working with state image indexes. /// Version 5.80. Displays a check box even if no image is associated with the item. /// /// Once a tree-view control is created with this style, the style cannot be removed. Instead, you must destroy the control and - /// create a new one in its place. Destroying the tree-view control does not destroy the check box state image list. You must - /// destroy it explicitly. Get the handle to the state image list by sending the tree-view control a TVM_GETIMAGELIST message. - /// Then destroy the image list with ImageList_Destroy. + /// create a new one in its place. Destroying the tree-view control does not destroy the check box state image list. You must destroy + /// it explicitly. Get the handle to the state image list by sending the tree-view control a TVM_GETIMAGELIST message. Then destroy + /// the image list with ImageList_Destroy. /// /// - /// If you want to use this style, you must set the TVS_CHECKBOXES style with SetWindowLong after you create the treeview - /// control, and before you populate the tree. Otherwise, the checkboxes might appear unchecked, depending on timing issues. + /// If you want to use this style, you must set the TVS_CHECKBOXES style with SetWindowLong after you create the treeview control, + /// and before you populate the tree. Otherwise, the checkboxes might appear unchecked, depending on timing issues. /// /// TVS_CHECKBOXES = 0x0100, @@ -2238,8 +2225,8 @@ public static partial class ComCtl32 TVS_FULLROWSELECT = 0x1000, /// - /// Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent - /// item's list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified. + /// Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item's + /// list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified. /// TVS_HASBUTTONS = 0x0001, @@ -2254,14 +2241,12 @@ public static partial class ComCtl32 /// TVS_LINESATROOT = 0x0004, - /// - /// Version 5.80. Disables horizontal scrolling in the control. The control will not display any horizontal scroll bars. - /// + /// Version 5.80. Disables horizontal scrolling in the control. The control will not display any horizontal scroll bars. TVS_NOHSCROLL = 0x8000, /// - /// Version 4.71 Sets the height of the items to an odd height with the TVM_SETITEMHEIGHT message. By default, the height of - /// items must be an even value. + /// Version 4.71 Sets the height of the items to an odd height with the TVM_SETITEMHEIGHT message. By default, the height of items + /// must be an even value. /// TVS_NONEVENHEIGHT = 0x4000, @@ -2274,10 +2259,10 @@ public static partial class ComCtl32 TVS_NOTOOLTIPS = 0x0080, /// - /// Version 4.70. Causes text to be displayed from right-to-left (RTL). Usually, windows display text left-to-right (LTR). - /// Windows can be mirrored to display languages such as Hebrew or Arabic that read RTL. Typically, tree-view text is displayed - /// in the same direction as the text in its parent window. If TVS_RTLREADING is set, tree-view text reads in the opposite - /// direction from the text in the parent window. + /// Version 4.70. Causes text to be displayed from right-to-left (RTL). Usually, windows display text left-to-right (LTR). Windows + /// can be mirrored to display languages such as Hebrew or Arabic that read RTL. Typically, tree-view text is displayed in the same + /// direction as the text in its parent window. If TVS_RTLREADING is set, tree-view text reads in the opposite direction from the + /// text in the parent window. /// TVS_RTLREADING = 0x0040, @@ -2285,12 +2270,12 @@ public static partial class ComCtl32 TVS_SHOWSELALWAYS = 0x0020, /// - /// Version 4.71. Causes the item being selected to expand and the item being unselected to collapse upon selection in the tree - /// view. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the user holds - /// down the CTRL key while selecting an item, the item being unselected will not be collapsed. + /// Version 4.71. Causes the item being selected to expand and the item being unselected to collapse upon selection in the tree view. + /// If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the user holds down the + /// CTRL key while selecting an item, the item being unselected will not be collapsed. /// - /// Version 5.80. Causes the item being selected to expand and the item being unselected to collapse upon selection in the tree - /// view. If the user holds down the CTRL key while selecting an item, the item being unselected will not be collapsed. + /// Version 5.80. Causes the item being selected to expand and the item being unselected to collapse upon selection in the tree view. + /// If the user holds down the CTRL key while selecting an item, the item being unselected will not be collapsed. /// /// TVS_SINGLEEXPAND = 0x0400, @@ -2321,9 +2306,7 @@ public static partial class ComCtl32 /// Windows Vista. Include exclusion checkbox state if the control has the TVS_CHECKBOXES style. TVS_EX_EXCLUSIONCHECKBOXES = 0x0100, - /// - /// Windows Vista. Fade expando buttons in or out when the mouse moves away or into a state of hovering over the control. - /// + /// Windows Vista. Fade expando buttons in or out when the mouse moves away or into a state of hovering over the control. TVS_EX_FADEINOUTEXPANDOS = 0x0040, /// Not supported. Do not use. @@ -2354,15 +2337,1745 @@ public static partial class ComCtl32 TVGIPR_BUTTON = 0x0001, } - /// Provides a handle to a tree view item. - [StructLayout(LayoutKind.Sequential)] - public readonly struct HTREEITEM - { - private readonly IntPtr handle; + /// + /// Prepares the index of a state image so that a tree-view control or list-view control can use the index to retrieve the state image + /// for an item. + /// + /// + /// Type: UINT + /// The index of a state image. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-indextostateimagemask void INDEXTOSTATEIMAGEMASK( i ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.INDEXTOSTATEIMAGEMASK")] + public static uint INDEXTOSTATEIMAGEMASK(uint index) => index << 12; - /// Initializes a new instance of the struct. - /// An object that represents the pre-existing handle to use. - public HTREEITEM(IntPtr preexistingHandle) => handle = preexistingHandle; + /// + /// Creates a dragging bitmap for the specified item in a tree-view control. The macro also creates an image list for the bitmap and adds + /// the bitmap to the image list. An application can display the image when dragging the item by using the image list functions. You can + /// use this macro or send the TVM_CREATEDRAGIMAGE message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item that receives the new dragging bitmap. + /// + /// None + /// + /// + /// If you create a tree-view control without an associated image list, you cannot use the TreeView_CreateDragImage macro to + /// create the image to display during a drag operation. You must implement your own method of creating a drag cursor. + /// + /// Your application is responsible for destroying the image list when it is no longer needed. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_createdragimage void TreeView_CreateDragImage( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_CreateDragImage")] + public static HIMAGELIST TreeView_CreateDragImage(HWND hwnd, HTREEITEM hitem) => + (HIMAGELIST)SendMessage(hwnd, TreeViewMessage.TVM_CREATEDRAGIMAGE, default, (IntPtr)hitem); + + /// Deletes all items from a tree-view control. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// Returns if the operation was successful, or otherwise. + /// + /// Once an item is deleted from a tree-view control, its HTREEITEM handle is invalid and cannot be used. + /// The parent window receives a TVN_DELETEITEM notification code when each item is removed. + /// + /// If the item label is being edited, the edit operation is canceled and the parent window receives the TVN_ENDLABELEDIT notification code. + /// + /// + /// You can also delete all items with the TreeView_DeleteItem macro or the TVM_DELETEITEM message by setting lParam to TVI_ROOT. + /// + /// + /// If the window style for a tree-view control contains TVS_NOSCROLL and all items are deleted, new items are not displayed until the + /// window styles are reset. The following code shows one way to ensure that items are always displayed. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_deleteallitems void TreeView_DeleteAllItems( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_DeleteAllItems")] + public static bool TreeView_DeleteAllItems(HWND hwnd) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_DELETEITEM, default, (IntPtr)HTREEITEM.TVI_ROOT); + + /// Removes an item and all its children from a tree-view control. You can also send the TVM_DELETEITEM message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// + /// HTREEITEM handle to the item to delete. If hitem is set to TVI_ROOT, all items are deleted from the tree-view control. + /// You can also use the TreeView_DeleteAllItems macro to delete all items. + /// + /// + /// Returns if the operation was successful, or otherwise. + /// + /// It is not safe to delete items in response to a notification such as TVN_SELCHANGING. + /// Once an item is deleted, its handle is invalid and cannot be used. + /// The parent window receives a TVN_DELETEITEM notification code when each item is removed. + /// + /// If the item label is being edited, the edit operation is canceled and the parent window receives the TVN_ENDLABELEDIT notification code. + /// + /// + /// If you delete all items in a tree-view control that has the TVS_NOSCROLL style, items subsequently added may not display properly. + /// For more information, see TreeView_DeleteAllItems. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_deleteitem void TreeView_DeleteItem( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_DeleteItem")] + public static bool TreeView_DeleteItem(HWND hwnd, HTREEITEM hitem) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_DELETEITEM, default, (IntPtr)hitem); + + /// + /// Begins in-place editing of the specified item's text, replacing the text of the item with a single-line edit control containing the + /// text. This macro implicitly selects and focuses the specified item. You can use this macro or send the TVM_EDITLABEL message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item to edit. + /// + /// None + /// + /// This macro sends a TVN_BEGINLABELEDIT notification code to the parent of the tree-view control. + /// + /// When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid. You can subclass the + /// edit control, but do not destroy it. + /// + /// The control must have the focus before you call this macro. Focus can be set using the SetFocus function. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_editlabel void TreeView_EditLabel( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_EditLabel")] + public static HWND TreeView_EditLabel(HWND hwnd, HTREEITEM hitem) => + (HWND)SendMessage(hwnd, TreeViewMessage.TVM_EDITLABEL, default, (IntPtr)hitem); + + /// Ends the editing of a tree-view item's label. You can use this macro or send the TVM_ENDEDITLABELNOW message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: BOOL + /// + /// Variable that indicates whether the editing is canceled without being saved to the label. If this parameter is TRUE, the + /// system cancels editing without saving the changes. Otherwise, the system saves the changes to the label. + /// + /// + /// None + /// This macro causes the TVN_ENDLABELEDIT notification code to be sent to the parent window of the tree-view control. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_endeditlabelnow void TreeView_EndEditLabelNow( hwnd, + // fCancel ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_EndEditLabelNow")] + public static bool TreeView_EndEditLabelNow(HWND hwnd, bool fCancel) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_ENDEDITLABELNOW, fCancel); + + /// + /// Ensures that a tree-view item is visible, expanding the parent item or scrolling the tree-view control, if necessary. You can use + /// this macro or send the TVM_ENSUREVISIBLE message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item. + /// + /// None + /// + /// If the TreeView_EnsureVisible macro expands the parent item, the parent window receives the TVN_ITEMEXPANDING and + /// TVN_ITEMEXPANDED notification codes. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_ensurevisible void TreeView_EnsureVisible( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_EnsureVisible")] + public static bool TreeView_EnsureVisible(HWND hwnd, HTREEITEM hitem) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_ENSUREVISIBLE, default, (IntPtr)hitem); + + /// + /// The TreeView_Expand macro expands or collapses the list of child items associated with the specified parent item, if any. You + /// can use this macro or send the TVM_EXPAND message explicitly. + /// + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the parent item that will be expanded or collapsed. + /// + /// + /// Type: UINT + /// Action flag. For a list of possible values, see the description of the flag parameter in TVM_EXPAND. + /// + /// Returns if the operation was successful, or otherwise. + /// + /// + /// Expanding a node that is already expanded, or collapsing a node that is already collapsed is considered a successful operation and + /// the macro returns a nonzero value. Attempting to expand or collapse a node that has no children is considered a failure and the + /// return value is zero. + /// + /// + /// When an item is first expanded by a TVM_EXPAND message, the action generates TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification + /// codes and the item's TVIS_EXPANDEDONCE state flag is set. As long as this state flag remains set, subsequent TVM_EXPAND + /// messages do not generate TVN_ITEMEXPANDING or TVN_ITEMEXPANDED notifications. To reset the TVIS_EXPANDEDONCE state flag, you + /// must send a TVM_EXPAND message with the TVE_COLLAPSE and TVE_COLLAPSERESET flags set. Attempting to explicitly set + /// TVIS_EXPANDEDONCE will result in unpredictable behavior. + /// + /// + /// The expand operation may fail if the owner of the treeview control denies the operation in response to a TVN_ITEMEXPANDING notification. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_expand void TreeView_Expand( hwnd, hitem, code ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_Expand")] + public static bool TreeView_Expand(HWND hwnd, HTREEITEM hitem, TreeViewExpandFlags code) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_EXPAND, (IntPtr)code, (IntPtr)hitem); + + /// Retrieves the current background color of the control. You can use this macro or send the TVM_GETBKCOLOR message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getbkcolor void TreeView_GetBkColor( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetBkColor")] + public static COLORREF TreeView_GetBkColor(HWND hwnd) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_GETBKCOLOR); + + /// Gets the check state of the specified item. You can also use the TVM_GETITEMSTATE message directly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item. + /// + /// None + /// + /// + /// A tree-view control can have two image lists. The normal image list stores the selected, nonselected, and overlay images. Check boxes + /// are stored in the state image list and displayed to the left of the corresponding normal image. State images are specified by a + /// one-based index. An index of zero indicates that there is no state image. See Tree-View Image Lists for a discussion of how to handle + /// tree-view images. + /// + /// + /// If you want to define your own state images, this macro assumes that the checked and unchecked images have the same indexes as the + /// standard image list: 1 for unchecked and 2 for checked. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getcheckstate void TreeView_GetCheckState( hwndTV, + // hti ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetCheckState")] + public static uint TreeView_GetCheckState(HWND hwndTV, HTREEITEM hti) => + (((uint)SendMessage(hwndTV, TreeViewMessage.TVM_GETITEMSTATE, (IntPtr)hti, TreeViewItemStates.TVIS_STATEIMAGEMASK)) >> 12) - 1; + + /// + /// Retrieves the first child item of the specified tree-view item. You can use this macro, or you can explicitly send the + /// TVM_GETNEXTITEM message with the TVGN_CHILD flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to a tree-view item. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getchild void TreeView_GetChild( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetChild")] + public static HTREEITEM TreeView_GetChild(HWND hwnd, HTREEITEM hitem) => + TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_CHILD); + + /// Retrieves a count of the items in a tree-view control. You can use this macro or send the TVM_GETCOUNT message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// The count of items. + /// + /// The node count returned by TreeView_GetCount is limited to integer values. If you add a node beyond 32767 the macro returns a + /// negative value. After adding 65536 nodes the count returns to zero. When this occurs, the tree-view control appears empty with no + /// scrollbars. For more information see the Knowledge Base article Q182231. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getcount void TreeView_GetCount( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetCount")] + public static int TreeView_GetCount(HWND hwnd) => + (int)SendMessage(hwnd, TreeViewMessage.TVM_GETCOUNT); + + /// + /// Retrieves the tree-view item that is the target of a drag-and-drop operation. You can use this macro, or you can explicitly send the + /// TVM_GETNEXTITEM message with the TVGN_DROPHILITE flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getdrophilight void TreeView_GetDropHilight( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetDropHilight")] + public static HTREEITEM TreeView_GetDropHilight(HWND hwnd) => TreeView_GetNextItem(hwnd, HTREEITEM.NULL, TreeViewActionFlag.TVGN_DROPHILITE); + + /// + /// Retrieves the handle to the edit control being used to edit a tree-view item's text. You can use this macro or send the + /// TVM_GETEDITCONTROL message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HWND + /// The handle to the edit control being used to edit a tree-view item's text, or NULL if no item is being edited. + /// + /// + /// + /// When label editing begins, an edit control is created but not positioned or displayed. Before it is displayed, the tree-view control + /// sends its parent window a TVN_BEGINLABELEDIT notification code. + /// + /// + /// To customize label editing, implement a handler for TVN_BEGINLABELEDIT and have it use TreeView_GetEditControl to send a + /// TVM_GETEDITCONTROL message to the tree-view control. If a label is being edited, the return value will be a handle to the edit + /// control. Use this handle to customize the edit control by sending the usual EM_XXX messages. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_geteditcontrol void TreeView_GetEditControl( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetEditControl")] + public static HWND TreeView_GetEditControl(HWND hwnd) => + (HWND)SendMessage(hwnd, TreeViewMessage.TVM_GETEDITCONTROL); + + /// + /// Retrieves the extended style for a specified tree-view control. Use this macro or send the TVM_GETEXTENDEDSTYLE message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + /// + /// The extended styles for a tree-view control have nothing to do with the extended styles used with function CreateWindowEx or function SetWindowLong. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getextendedstyle void TreeView_GetExtendedStyle( + // hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetExtendedStyle")] + public static TreeViewStyleEx TreeView_GetExtendedStyle(HWND hwnd) => + (TreeViewStyleEx)(int)SendMessage(hwnd, TreeViewMessage.TVM_GETEXTENDEDSTYLE); + + /// + /// Retrieves the first visible item in a tree-view control window. You can use this macro, or you can explicitly send the + /// TVM_GETNEXTITEM message with the TVGN_FIRSTVISIBLE flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getfirstvisible void TreeView_GetFirstVisible( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetFirstVisible")] + public static HTREEITEM TreeView_GetFirstVisible(HWND hwnd) => TreeView_GetNextItem(hwnd, HTREEITEM.NULL, TreeViewActionFlag.TVGN_FIRSTVISIBLE); + + /// + /// Retrieves the handle to the normal or state image list associated with a tree-view control. You can use this macro or send the + /// TVM_GETIMAGELIST message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: INT + /// Type of image list to retrieve. This parameter can be one of the following values: + /// + /// + /// Value + /// Meaning + /// + /// + /// TVSIL_NORMAL + /// + /// Indicates the normal image list, which contains selected, nonselected, and overlay images for the items of a tree-view control. + /// + /// + /// + /// TVSIL_STATE + /// + /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed to + /// the left of an item's selected or nonselected image. + /// + /// + /// + /// + /// Returns an HIMAGELIST handle to the specified image list. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getimagelist void TreeView_GetImageList( hwnd, + // iImage ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetImageList")] + public static HIMAGELIST TreeView_GetImageList(HWND hwnd, TreeViewSetImageListType iImage) => + (HIMAGELIST)SendMessage(hwnd, TreeViewMessage.TVM_GETIMAGELIST, iImage); + + /// + /// Retrieves the amount, in pixels, that child items are indented relative to their parent items. You can use this macro or send the + /// TVM_GETINDENT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// The amount of indentation. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getindent void TreeView_GetIndent( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetIndent")] + public static int TreeView_GetIndent(HWND hwnd) => + (int)SendMessage(hwnd, TreeViewMessage.TVM_GETINDENT); + + /// + /// Retrieves the color used to draw the insertion mark for the tree view. You can use this macro or send the TVM_GETINSERTMARKCOLOR + /// message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getinsertmarkcolor void TreeView_GetInsertMarkColor( + // hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetInsertMarkColor")] + public static COLORREF TreeView_GetInsertMarkColor(HWND hwnd) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_GETINSERTMARKCOLOR); + + /// + /// Retrieves the incremental search string for a tree-view control. The tree-view control uses the incremental search string to select + /// an item based on characters typed by the user. You can use this macro or send the TVM_GETISEARCHSTRING message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTSTR + /// Pointer to the buffer that receives the incremental search string. + /// + /// None + /// + /// If the tree-view control is not in incremental search mode, the return value is zero. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getisearchstring void TreeView_GetISearchString( + // hwndTV, lpsz ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetISearchString")] + public static bool TreeView_GetISearchString(HWND hwndTV, out string? lpsz) + { + using SafeLPTSTR str = new(2048); + BOOL ret = SendMessage(hwndTV, TreeViewMessage.TVM_GETISEARCHSTRING, default, str.DangerousGetHandle()); + lpsz = (string?)str; + return ret; + } + + /// Retrieves some or all of a tree-view item's attributes. You can use this macro or send the TVM_GETITEM message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTVITEM + /// + /// Pointer to a TVITEM structure that specifies the information to retrieve and receives information about the item. With version 4.71 + /// and later, you can use a TVITEMEX structure instead. + /// + /// + /// None + /// + /// + /// When the TVM_GETITEM message is sent, the hItem member of the TVITEM or TVITEMEX structure identifies the item to retrieve + /// information about, and the mask member specifies the attributes to retrieve. + /// + /// + /// If the TVIF_TEXT flag is set in the mask member of the TVITEM or TVITEMEX structure, the pszText member must point to a + /// valid buffer and the cchTextMax member must be set to the number of characters in that buffer. The returned text will not + /// necessarily be stored in the original buffer passed by the application. It is possible that pszText will point to text in a + /// new buffer rather than place it in the old buffer. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getitem void TreeView_GetItem( hwnd, pitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetItem")] + public static bool TreeView_GetItem(HWND hwnd, ref TVITEM pitem) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_GETITEM, default, ref pitem); + + /// Retrieves the current height of the tree-view items. You can use this macro or send the TVM_GETITEMHEIGHT message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// Height of each item, in pixels. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getitemheight void TreeView_GetItemHeight( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetItemHeight")] + public static short TreeView_GetItemHeight(HWND hwnd) => + (short)(int)SendMessage(hwnd, TreeViewMessage.TVM_GETITEMHEIGHT); + + /// + /// Retrieves the largest possible bounding rectangle that constitutes the "hit zone" for a specified part of an item. Use this macro or + /// send the TVM_GETITEMPARTRECT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the tree-view item. + /// + /// + /// Type: TVITEMPART* + /// ID of the item part. This value must be TVGIPR_BUTTON (0x0001). + /// + /// + /// A RECT structure that receives the bounding rectangle on success, or on failure. The coordinates received are + /// relative to the upper-left corner of the tree-view control. + /// + /// + /// This message returns the largest possible bounding rectangle such that for every (x,y) coordinate within the rectangle, a click by + /// the user at that coordinate would constitute a hit on that part of the item. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getitempartrect void TreeView_GetItemPartRect( hwnd, + // hitem, prc, partid ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetItemPartRect")] + public static RECT? TreeView_GetItemPartRect(HWND hwnd, HTREEITEM hitem, TVITEMPART partid = TVITEMPART.TVGIPR_BUTTON) + { + using SafeCoTaskMemStruct prc = new(); + TVGETITEMPARTRECTINFO info = new(hitem) + { + prc = prc, + partID = partid + }; + return SendMessage(hwnd, TreeViewMessage.TVM_GETITEMPARTRECT, IntPtr.Zero, ref info) != IntPtr.Zero ? info.Bounds : null; + } + + /// + /// Retrieves the bounding rectangle for a tree-view item and indicates whether the item is visible. You can use this macro or send the + /// TVM_GETITEMRECT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the tree-view item. + /// + /// + /// Type: BOOL + /// + /// Value specifying the portion of the item for which to retrieve the bounding rectangle. If this parameter is TRUE, the bounding + /// rectangle includes only the text of the item. Otherwise, it includes the entire line that the item occupies in the tree-view control. + /// + /// + /// + /// Nullable RECT structure that receives the bounding rectangle if the item is visible and the bounding rectangle was successfully + /// retrieved. The coordinates are relative to the upper-left corner of the tree-view control. Returns if the + /// bounding rectangle was not recieved. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getitemrect void TreeView_GetItemRect( hwnd, hitem, + // prc, code ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetItemRect")] + public static RECT? TreeView_GetItemRect(HWND hwnd, HTREEITEM hitem, bool onlyText = false) + { + unsafe + { + RECT rc = default; + *(HTREEITEM*)&rc = hitem; + BOOL ret = SendMessage(hwnd, TreeViewMessage.TVM_GETITEMRECT, (IntPtr)(BOOL)onlyText, (IntPtr)(void*)&rc); + return ret ? rc : null; + } + } + + /// + /// Retrieves some or all of a tree-view item's state attributes. You can use this macro or send the TVM_GETITEMSTATE message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item. + /// + /// + /// Type: UINT + /// Mask used to specify the states to query for. It is equivalent to the stateMask member of TVITEMEX. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getitemstate void TreeView_GetItemState( hwndTV, + // hti, mask ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetItemState")] + public static uint TreeView_GetItemState(HWND hwndTV, HTREEITEM hti, TreeViewItemStates mask) => + (uint)SendMessage(hwndTV, TreeViewMessage.TVM_GETITEMSTATE, (IntPtr)hti, mask); + + /// + /// Retrieves the last expanded item in a tree-view control. This does not retrieve the last item visible in the tree-view window. You + /// can use this macro, or you can explicitly send the TVM_GETNEXTITEM message with the TVGN_LASTVISIBLE flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getlastvisible void TreeView_GetLastVisible( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetLastVisible")] + public static HTREEITEM TreeView_GetLastVisible(HWND hwnd) => TreeView_GetNextItem(hwnd, HTREEITEM.NULL, TreeViewActionFlag.TVGN_LASTVISIBLE); + + /// Gets the current line color. You can also use the TVM_GETLINECOLOR message directly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + /// + /// This message only retrieves line colors. To retrieve the colors of the plus sign (+) and minus sign (-) inside the buttons, use the + /// TreeView_GetTextColor macro. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getlinecolor void TreeView_GetLineColor( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetLineColor")] + public static COLORREF TreeView_GetLineColor(HWND hwnd) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_GETLINECOLOR); + + /// + /// Retrieves the tree-view item that bears the specified relationship to a specified item. You can use this macro, use one of the + /// TreeView_Get macros described below, or send the TVM_GETNEXTITEM message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. + /// + /// + /// Type: UINT + /// Flag specifying the item to retrieve. This parameter can be one of the following values: + /// + /// + /// Value + /// Meaning + /// + /// + /// TVGN_CARET + /// Retrieves the currently selected item. You can use the TreeView_GetSelection macro to send this message. + /// + /// + /// TVGN_CHILD + /// + /// Retrieves the first child item of the item specified by the hitem parameter. You can use the TreeView_GetChild macro to send + /// this message. + /// + /// + /// + /// TVGN_DROPHILITE + /// + /// Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to send this message. + /// + /// + /// + /// TVGN_FIRSTVISIBLE + /// Retrieves the first visible item. You can use the TreeView_GetFirstVisible macro to send this message. + /// + /// + /// TVGN_NEXT + /// Retrieves the next sibling item. You can use the TreeView_GetNextSibling macro to send this message. + /// + /// + /// TVGN_NEXTSELECTED + /// + /// Windows Vista and later. Retrieves the next selected item. You can use the TreeView_GetNextSelected macro to send this message. + /// + /// + /// + /// TVGN_NEXTVISIBLE + /// + /// Retrieves the next visible item that follows the specified item. The specified item must be visible. Use the TVM_GETITEMRECT message + /// to determine whether an item is visible. You can use the TreeView_GetNextVisible macro to send this message. + /// + /// + /// + /// TVGN_PARENT + /// Retrieves the parent of the specified item. You can use the TreeView_GetParent macro to send this message. + /// + /// + /// TVGN_PREVIOUS + /// Retrieves the previous sibling item. You can use the TreeView_GetPrevSibling macro to send this message. + /// + /// + /// TVGN_PREVIOUSVISIBLE + /// + /// Retrieves the first visible item that precedes the specified item. The specified item must be visible. Use the TVM_GETITEMRECT + /// message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro to send this message. + /// + /// + /// + /// TVGN_ROOT + /// + /// Retrieves the topmost or very first item of the tree-view control. You can use the TreeView_GetRoot macro to send this message. + /// + /// + /// + /// + /// + /// Returns the handle to the item if successful. For most cases, the message returns a NULL value to indicate an error. + /// + /// + /// This macro will return NULL if the item being retrieved is the root node of the tree. For example, if you use this macro with + /// the TVGN_PARENT flag on a first-level child of the tree view's root node, the macro will return NULL. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getnextitem void TreeView_GetNextItem( hwnd, hitem, + // code ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetNextItem")] + public static HTREEITEM TreeView_GetNextItem(HWND hwnd, HTREEITEM hitem, TreeViewActionFlag code) => + (HTREEITEM)SendMessage(hwnd, TreeViewMessage.TVM_GETNEXTITEM, code, (IntPtr)hitem); + + /// Retrieves the tree-view item that bears the TVGN_NEXTSELECTED relationship to a specified tree item. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM* + /// Specifies the tree item by handle. + /// + /// None + /// Used to find the next selected item when there are multiple items selected. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getnextselected void TreeView_GetNextSelected( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetNextSelected")] + public static HTREEITEM TreeView_GetNextSelected(HWND hwnd, HTREEITEM hitem) => TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_NEXTSELECTED); + + /// + /// Retrieves the next sibling item of a specified item in a tree-view control. You can use this macro, or you can explicitly send the + /// TVM_GETNEXTITEM message with the TVGN_NEXT flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getnextsibling void TreeView_GetNextSibling( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetNextSibling")] + public static HTREEITEM TreeView_GetNextSibling(HWND hwnd, HTREEITEM hitem) => TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_NEXT); + + /// + /// Retrieves the next visible item that follows a specified item in a tree-view control. You can use this macro, or you can explicitly + /// send the TVM_GETNEXTITEM message with the TVGN_NEXTVISIBLE flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. The specified item must be visible. Use the TVM_GETITEMRECT message to determine whether an item is visible. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getnextvisible void TreeView_GetNextVisible( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetNextVisible")] + public static HTREEITEM TreeView_GetNextVisible(HWND hwnd, HTREEITEM hitem) => TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_NEXTVISIBLE); + + /// + /// Retrieves the parent item of the specified tree-view item. You can use this macro, or you can explicitly send the TVM_GETNEXTITEM + /// message with the TVGN_PARENT flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. + /// + /// + /// Type: HWND + /// The handle to the parent item of this tree-view item, or NULL. + /// + /// This macro will return NULL if the parent of the specified item is the root node of the tree. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getparent void TreeView_GetParent( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetParent")] + public static HTREEITEM TreeView_GetParent(HWND hwnd, HTREEITEM hitem) => TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_PARENT); + + /// + /// Retrieves the previous sibling item of a specified item in a tree-view control. You can use this macro, or you can explicitly send + /// the TVM_GETNEXTITEM message with the TVGN_PREVIOUS flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getprevsibling void TreeView_GetPrevSibling( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetPrevSibling")] + public static HTREEITEM TreeView_GetPrevSibling(HWND hwnd, HTREEITEM hitem) => TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_PREVIOUS); + + /// + /// Retrieves the first visible item that precedes a specified item in a tree-view control. You can use this macro, or you can explicitly + /// send the TVM_GETNEXTITEM message with the TVGN_PREVIOUSVISIBLE flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. The specified item must be visible. Use the TVM_GETITEMRECT message to determine whether an item is visible. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getprevvisible void TreeView_GetPrevVisible( hwnd, + // hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetPrevVisible")] + public static HTREEITEM TreeView_GetPrevVisible(HWND hwnd, HTREEITEM hitem) => TreeView_GetNextItem(hwnd, hitem, TreeViewActionFlag.TVGN_PREVIOUSVISIBLE); + + /// + /// Retrieves the topmost or very first item of the tree-view control. You can use this macro, or you can explicitly send the + /// TVM_GETNEXTITEM message with the TVGN_ROOT flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getroot void TreeView_GetRoot( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetRoot")] + public static HTREEITEM TreeView_GetRoot(HWND hwnd) => TreeView_GetNextItem(hwnd, HTREEITEM.NULL, TreeViewActionFlag.TVGN_ROOT); + + /// + /// Retrieves the maximum scroll time for the tree-view control. You can use this macro or send the TVM_GETSCROLLTIME message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + /// + /// The maximum scroll time is the longest amount of time that a scroll operation can take. Scrolling will be adjusted so that the scroll + /// will take place within the maximum scroll time. A scroll operation may take less time than the maximum. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getscrolltime void TreeView_GetScrollTime( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetScrollTime")] + public static uint TreeView_GetScrollTime(HWND hwnd) => + (uint)SendMessage(hwnd, TreeViewMessage.TVM_GETSCROLLTIME); + + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getselectedcount void TreeView_GetSelectedCount( + // [in] hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetSelectedCount")] + public static uint TreeView_GetSelectedCount(HWND hwnd) => + (uint)SendMessage(hwnd, TreeViewMessage.TVM_GETSELECTEDCOUNT); + + /// + /// Retrieves the currently selected item in a tree-view control. You can use this macro, or you can explicitly send the TVM_GETNEXTITEM + /// message with the TVGN_CARET flag. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getselection void TreeView_GetSelection( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetSelection")] + public static HTREEITEM TreeView_GetSelection(HWND hwnd) => TreeView_GetNextItem(hwnd, HTREEITEM.NULL, TreeViewActionFlag.TVGN_CARET); + + /// Retrieves the current text color of the control. You can use this macro or send the TVM_GETTEXTCOLOR message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_gettextcolor void TreeView_GetTextColor( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetTextColor")] + public static COLORREF TreeView_GetTextColor(HWND hwnd) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_GETTEXTCOLOR); + + /// + /// Retrieves the handle to the child tooltip control used by a tree-view control. You can use this macro or send the TVM_GETTOOLTIPS + /// message explicitly. + /// + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// None + /// + /// When created, tree-view controls automatically create a child tooltip control. To prevent a tree-view control from using tooltips, + /// create the control with the TVS_NOTOOLTIPS style. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_gettooltips void TreeView_GetToolTips( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetToolTips")] + public static HWND TreeView_GetToolTips(HWND hwnd) => + (HWND)SendMessage(hwnd, TreeViewMessage.TVM_GETTOOLTIPS); + + /// + /// Retrieves the Unicode character format flag for the control. You can use this macro or send the TVM_GETUNICODEFORMAT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the control. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getunicodeformat void TreeView_GetUnicodeFormat( + // hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetUnicodeFormat")] + public static bool TreeView_GetUnicodeFormat(HWND hwnd) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_GETUNICODEFORMAT); + + /// + /// Obtains the number of items that can be fully visible in the client window of a tree-view control. You can use this macro or send the + /// TVM_GETVISIBLECOUNT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// None + /// + /// + /// The number of items that can be fully visible may be greater than the number of items in the control. The control calculates this + /// value by dividing the height of the client window by the height of an item. + /// + /// + /// Note that the return value is the number of items that can be fully visible. If you can see all of 20 items and part of one + /// more item, the return value is 20. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_getvisiblecount void TreeView_GetVisibleCount( hwnd ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_GetVisibleCount")] + public static int TreeView_GetVisibleCount(HWND hwnd) => + (int)SendMessage(hwnd, TreeViewMessage.TVM_GETVISIBLECOUNT); + + /// + /// Determines the location of the specified point relative to the client area of a tree-view control. You can use this macro or send the + /// TVM_HITTEST message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTVHITTESTINFO + /// + /// Pointer to a TVHITTESTINFO structure. When the message is sent, the pt member specifies the coordinates of the point to test. + /// When the message returns, the hItem member is the handle to the item at the specified point or NULL if no item occupies + /// the point. Also, when the message returns, the flags member is a hit test value that indicates the location of the specified + /// point. For a list of hit test values, see the description of the TVHITTESTINFO structure. + /// + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_hittest void TreeView_HitTest( hwnd, lpht ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_HitTest")] + public static HTREEITEM TreeView_HitTest(HWND hwnd, ref TVHITTESTINFO lpht) => + (HTREEITEM)SendMessage(hwnd, TreeViewMessage.TVM_HITTEST, default, ref lpht); + + /// Inserts a new item in a tree-view control. You can use this macro or send the TVM_INSERTITEM message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTVINSERTSTRUCT + /// Pointer to a TVINSERTSTRUCT structure that specifies the attributes of the tree-view item. + /// + /// Returns the HTREEITEM handle to the new item if successful, or NULL otherwise. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_insertitem void TreeView_InsertItem( hwnd, lpis ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_InsertItem")] + public static HTREEITEM TreeView_InsertItem(HWND hwnd, ref TVINSERTSTRUCT lpis) => + (HTREEITEM)SendMessage(hwnd, TreeViewMessage.TVM_INSERTITEM, default, ref lpis); + + /// Maps an accessibility ID to an HTREEITEM. You can use this macro or send the TVM_MAPACCIDTOHTREEITEM message explicitly. + /// + /// Type: HWND + /// A handle to the list-view control. + /// + /// + /// Type: UINT + /// The accessibility ID to map to an HTREEITEM. + /// + /// None + /// + /// + /// To use TreeView_MapAccIDToHTREEITEM, specify Comctl32.dll version 6 in the manifest. For more information on manifests, see + /// Enabling Visual Styles. + /// + /// + /// Note  The accessibility ID is not the same as that mentioned in IAccessibleObject. This is a unique ID used for treeview items + /// as long as treeitems do not exceed the max limit of UINT. + /// + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_mapaccidtohtreeitem void + // TreeView_MapAccIDToHTREEITEM( hwnd, id ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_MapAccIDToHTREEITEM")] + public static HTREEITEM TreeView_MapAccIDToHTREEITEM(HWND hwnd, uint id) => + (HTREEITEM)SendMessage(hwnd, TreeViewMessage.TVM_MAPACCIDTOHTREEITEM, id); + + /// Maps an HTREEITEM to an accessibility ID. You can use this macro or send the TVM_MAPHTREEITEMTOACCID message explicitly. + /// + /// Type: HWND + /// Handle to the list-view control. + /// + /// + /// Type: HTREEITEM + /// The value to be mapped. + /// + /// None + /// + /// + /// To use TreeView_MapHTREEITEMtoAccID, specify Comctl32.dll version 6 in the manifest. For more information on manifests, see + /// Enabling Visual Styles. + /// + /// + /// Note  The accessibility ID is not the same as that mentioned in IAccessibleObject. This is a unique ID used for treeview items + /// as long as treeitems do not exceed the max limit of UINT. + /// + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_maphtreeitemtoaccid void + // TreeView_MapHTREEITEMToAccID( hwnd, htreeitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_MapHTREEITEMToAccID")] + public static uint TreeView_MapHTREEITEMToAccID(HWND hwnd, HTREEITEM htreeitem) => + (uint)SendMessage(hwnd, TreeViewMessage.TVM_MAPHTREEITEMTOACCID, (IntPtr)htreeitem); + + /// + /// Selects the specified tree-view item, scrolls the item into view, or redraws the item in the style used to indicate the target of a + /// drag-and-drop operation. You can use this macro or the TreeView_SelectItem, TreeView_SelectSetFirstVisible, or + /// TreeView_SelectDropTarget macros, or you can send the TVM_SELECTITEM message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. If the hitem parameter is NULL, the control is set to have no selected item. + /// + /// + /// Type: UINT + /// Action flag. This parameter can be one of the following values: + /// + /// + /// Value + /// Meaning + /// + /// + /// TVGN_CARET + /// + /// Sets the selection to the given item. The control's parent window receives the TVN_SELCHANGING and TVN_SELCHANGED notification codes. + /// + /// + /// + /// TVGN_DROPHILITE + /// Redraws the given item in the style used to indicate the target of a drag-and-drop operation. + /// + /// + /// TVGN_FIRSTVISIBLE + /// + /// Ensures that the specified item is visible, and, if possible, displays it at the top of the control's window. Tree-view controls + /// display as many items as will fit in the window. If the specified item is near the bottom of the control's hierarchy of items, it + /// might not become the first visible item, depending on how many items fit in the window. + /// + /// + /// + /// + /// None + /// + /// If the specified item is the child of a collapsed parent item, the parent's list of child items is expanded to reveal the specified + /// item. In this case, the parent window receives the TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_select void TreeView_Select( hwnd, hitem, code ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_Select")] + public static bool TreeView_Select(HWND hwnd, HTREEITEM hitem, TreeViewActionFlag code) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SELECTITEM, code, (IntPtr)hitem); + + /// + /// Redraws a specified tree-view control item in the style used to indicate the target of a drag-and-drop operation. You can use this + /// macro or the TreeView_Select macro, or you can send the TVM_SELECTITEM message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. If the hitem parameter is NULL, the control is set to have no selected item. + /// + /// None + /// + /// + /// If the specified item is the child of a collapsed parent item, the parent's list of child items is expanded to reveal the specified + /// item. In this case, the parent window receives the TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes. + /// + /// + /// Using the TreeView_SelectDropTarget macro is equivalent to sending the TVM_SELECTITEM message with its flag parameter + /// set to the TVGN_DROPHILITE value. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_selectdroptarget void TreeView_SelectDropTarget( + // hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SelectDropTarget")] + public static bool TreeView_SelectDropTarget(HWND hwnd, HTREEITEM hitem) => TreeView_Select(hwnd, hitem, TreeViewActionFlag.TVGN_DROPHILITE); + + /// + /// Selects the specified tree-view item. You can use this macro or the TreeView_Select macro, or you can send the TVM_SELECTITEM message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. If the hitem parameter is NULL, the control is set to have no selected item. + /// + /// None + /// + /// + /// When you call the TreeView_SelectItem macro, the control's parent window receives the TVN_SELCHANGING and TVN_SELCHANGED + /// notification codes. Also, if the specified item is the child of a collapsed parent item, the parent's list of child items is expanded + /// to reveal the specified item. In this case, the parent window receives the TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes. + /// + /// + /// Using the TreeView_SelectItem macro is equivalent to sending the TVM_SELECTITEM message with its flag parameter set to + /// the TVGN_CARET value. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_selectitem void TreeView_SelectItem( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SelectItem")] + public static bool TreeView_SelectItem(HWND hwnd, HTREEITEM hitem) => TreeView_Select(hwnd, hitem, TreeViewActionFlag.TVGN_CARET); + + /// + /// Scrolls the tree-view control vertically to ensure that the specified item is visible. If possible, the specified item becomes the + /// first visible item at the top of the control's window. You can use this macro or the TreeView_Select macro, or you can send the + /// TVM_SELECTITEM message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to an item. If the hitem parameter is NULL, the control is set to have no selected item. + /// + /// None + /// + /// + /// Tree-view controls display as many items as will fit in the window. If the specified item is near the bottom of the control's + /// hierarchy of items, it might not become the first visible item, depending on how many items fit in the window. + /// + /// + /// If the specified item is the child of a collapsed parent item, the parent's list of child items is expanded to reveal the specified + /// item. In this case, the parent window receives the TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification codes. + /// + /// + /// Using the TreeView_SelectSetFirstVisible macro is equivalent to sending the TVM_SELECTITEM message with its flag + /// parameter set to the TVGN_FIRSTVISIBLE value. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_selectsetfirstvisible void + // TreeView_SelectSetFirstVisible( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SelectSetFirstVisible")] + public static bool TreeView_SelectSetFirstVisible(HWND hwnd, HTREEITEM hitem) => TreeView_Select(hwnd, hitem, TreeViewActionFlag.TVGN_FIRSTVISIBLE); + + /// + /// Sets information used to determine auto-scroll characteristics. Use this macro or send the TVM_SETAUTOSCROLLINFO message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: UINT + /// + /// Specifies pixels per second. The offset to scroll is divided by the uPixPerSec to determine the total duration of the auto-scroll. + /// + /// + /// + /// Type: UINT + /// + /// Specifies the redraw time interval. Redraw at every elapsed interval, until the item is scrolled into view. Given uPixPerSec, + /// the location of the item is calculated and a repaint occurs. Set this value to create smooth scrolling. + /// + /// + /// None + /// + /// Autoscroll information is used to scroll a nonvisible item into view. The control must have the TVS_EX_AUTOHSCROLL extended style. + /// For information on extended styles, see Tree-View Control Extended Styles. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setautoscrollinfo void TreeView_SetAutoScrollInfo( + // hwnd, uPixPerSec, uUpdateTime ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetAutoScrollInfo")] + public static void TreeView_SetAutoScrollInfo(HWND hwnd, uint uPixPerSec, uint uUpdateTime) => + SendMessage(hwnd, TreeViewMessage.TVM_SETAUTOSCROLLINFO, (IntPtr)uPixPerSec, (IntPtr)uUpdateTime); + + /// Sets the background color of the control. You can use this macro or send the TVM_SETBKCOLOR message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: COLORREF + /// + /// COLORREF value that contains the new background color. If this argument is -1, the control will revert to using the system color for + /// the background color. + /// + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setbkcolor void TreeView_SetBkColor( hwnd, clr ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetBkColor")] + public static COLORREF TreeView_SetBkColor(HWND hwnd, COLORREF clr) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_SETBKCOLOR, default, (IntPtr)clr.ToArgb()); + + /// + /// Sets the size of the border for the items in a tree-view control. You can use this macro or send the TVM_SETBORDER message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: DWORD + /// Action flags. This parameter can be one or more of the following values: + /// + /// + /// Value + /// Meaning + /// + /// + /// TVSBF_XBORDER + /// Applies the specified border size to the left side of the items in the tree-view control. + /// + /// + /// TVSBF_YBORDER + /// Applies the specified border size to the top of the items in the tree-view control. + /// + /// + /// + /// + /// Type: SHORT + /// Size of the left border, in pixels. + /// + /// + /// Type: SHORT + /// Size of the top border, in pixels. + /// + /// None + /// The item border is set just for spacing purposes. A successful setting triggers a recalculation of the scroll bars. + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setborder void TreeView_SetBorder( hwnd, dwFlags, + // xBorder, yBorder ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetBorder")] + public static uint TreeView_SetBorder(HWND hwnd, TreeViewSetBorderFlags dwFlags, ushort xBorder, ushort yBorder) => + (uint)SendMessage(hwnd, TreeViewMessage.TVM_SETBORDER, (IntPtr)dwFlags, Macros.MAKELPARAM(xBorder, yBorder)); + + /// Sets the item's state image to "checked" or "unchecked." You can also use the TVM_SETITEM message directly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item. + /// + /// + /// Type: BOOL + /// + /// Value that indicates which state image is displayed. Set fCheck to TRUE to display the checked state image or + /// FALSE to display the unchecked image. + /// + /// + /// None + /// + /// + /// A tree-view control can have two image lists. The normal image list stores the selected, nonselected, and overlay images. Check boxes + /// are stored in the state image list and displayed to the left of the corresponding normal image. State images are specified by a + /// one-based index. An index of zero indicates that there is no state image. See Tree-View Image Lists for a discussion of how to handle + /// tree-view images. + /// + /// + /// If you want to define your own state images, this macro assumes that the checked and unchecked images have the same indexes as the + /// standard image list: 1 for unchecked and 2 for checked. + /// + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setcheckstate void TreeView_SetCheckState( hwndTV, + // hti, fCheck ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetCheckState")] + public static bool TreeView_SetCheckState(HWND hwndTV, HTREEITEM hti, bool fCheck) => + TreeView_SetItemState(hwndTV, hti, INDEXTOSTATEIMAGEMASK(fCheck ? 2U : 1U), TreeViewItemStates.TVIS_STATEIMAGEMASK); + + /// Sets the extended style for a specified TreeView control. Use this macro or send the TVM_SETEXTENDEDSTYLE message explicitly. + /// + /// Type: HWND + /// Handle to the TreeView control. + /// + /// + /// Type: DWORD + /// Value that indicates the extended style. For more information on styles, see Tree-View Control Extended Styles. + /// + /// + /// Type: UINT + /// Mask used to select the styles to be set. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setextendedstyle void TreeView_SetExtendedStyle( + // hwnd, dw, mask ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetExtendedStyle")] + public static HRESULT TreeView_SetExtendedStyle(HWND hwnd, TreeViewStyleEx dw, TreeViewStyleEx mask) => + (HRESULT)(int)SendMessage(hwnd, TreeViewMessage.TVM_SETEXTENDEDSTYLE, mask, (IntPtr)(int)dw); + + /// Sets the hot item for a tree-view control. You can use this macro or send the TVM_SETHOT message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the new hot item. If this value is NULL, the tree-view control will be set to have no hot item. + /// + /// None + /// + /// + /// The hot item is the item that the mouse is hovering over. The TVM_SETHOT message sent by this macro makes an item look like it + /// is the hot item even if the mouse is not hovering over it. + /// + /// The TVM_SETHOT message has no visible effect if the TVS_TRACKSELECT style is not set. + /// If it succeeds, the TVM_SETHOT message causes the hot item to be redrawn. + /// The TVM_SETHOT message is ignored if hitem is NULL and the tree-view control is tracking the mouse. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_sethot void TreeView_SetHot( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetHot")] + public static void TreeView_SetHot(HWND hwnd, HTREEITEM hitem) => + SendMessage(hwnd, TreeViewMessage.TVM_SETHOT, default, (IntPtr)hitem); + + /// + /// Sets the normal or state image list for a tree-view control and redraws the control using the new images. You can use this macro or + /// send the TVM_SETIMAGELIST message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HIMAGELIST + /// + /// The HIMAGELIST handle to the image list. If himl is NULL, the message removes the specified image list from the + /// tree-view control. + /// + /// + /// + /// Type: INT + /// Type of image list to set. This parameter can be one of the following values: + /// + /// + /// Value + /// Meaning + /// + /// + /// TVSIL_NORMAL + /// + /// Indicates the normal image list, which contains selected, nonselected, and overlay images for the items of a tree-view control. + /// + /// + /// + /// TVSIL_STATE + /// + /// Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed to + /// the left of an item's selected or nonselected image. + /// + /// + /// + /// + /// Returns the handle to the previous image list, if any, or NULL otherwise. + /// + /// The tree-view control will not destroy the image list specified with this message. Your application must destroy the image list when + /// it is no longer needed. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setimagelist void TreeView_SetImageList( hwnd, himl, + // iImage ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetImageList")] + public static HIMAGELIST TreeView_SetImageList(HWND hwnd, HIMAGELIST himl, TreeViewSetImageListType iImage) => + (HIMAGELIST)SendMessage(hwnd, TreeViewMessage.TVM_SETIMAGELIST, iImage, (IntPtr)himl); + + /// + /// Sets the width of indentation for a tree-view control and redraws the control to reflect the new width. You can use this macro or + /// send the TVM_SETINDENT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: INT + /// + /// Width, in pixels, of the indentation. If this parameter is less than the system-defined minimum width, the new width is set to the + /// system-defined minimum. + /// + /// + /// None + /// + /// The system-defined minimum indent value is typically five pixels, but it is not fixed. To retrieve the exact value of the minimum + /// indent on a particular system, use the TreeView_SetIndent macro with indent set to zero. Then use the + /// TreeView_GetIndent macro to retrieve the minimum indent value. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setindent void TreeView_SetIndent( hwnd, indent ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetIndent")] + public static bool TreeView_SetIndent(HWND hwnd, int indent) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SETINDENT, (IntPtr)indent); + + /// Sets the insertion mark in a tree-view control. You can use this macro or send the TVM_SETINSERTMARK message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: HTREEITEM + /// + /// HTREEITEM that specifies at which item the insertion mark will be placed. If this argument is NULL, the insertion mark + /// is removed. + /// + /// + /// + /// Type: BOOL + /// + /// BOOL value that specifies if the insertion mark is placed before or after the specified item. If this argument is nonzero, the + /// insertion mark will be placed after the item. If this argument is zero, the insertion mark will be placed before the item. + /// + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setinsertmark void TreeView_SetInsertMark( hwnd, + // hItem, fAfter ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetInsertMark")] + public static bool TreeView_SetInsertMark(HWND hwnd, HTREEITEM hItem, bool fAfter) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SETINSERTMARK, fAfter, (IntPtr)hItem); + + /// + /// Sets the color used to draw the insertion mark for the tree view. You can use this macro or send the TVM_SETINSERTMARKCOLOR message explicitly. + /// + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: COLORREF + /// COLORREF value that contains the new insertion mark color. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setinsertmarkcolor void TreeView_SetInsertMarkColor( + // hwnd, clr ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetInsertMarkColor")] + public static COLORREF TreeView_SetInsertMarkColor(HWND hwnd, COLORREF clr) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_SETINSERTMARKCOLOR, default, (IntPtr)clr.ToArgb()); + + /// + /// The TreeView_SetItem macro sets some or all of a tree-view item's attributes. You can use this macro or send the TVM_SETITEM + /// message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTVITEM + /// + /// Pointer to a TVITEM structure that contains the new item attributes. With version 4.71 and later, you can instead use a TVITEMEX structure. + /// + /// + /// None + /// + /// The hItem member of the TVITEM or TVITEMEX structure identifies the item, and the mask member specifies which + /// attributes to set. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setitem void TreeView_SetItem( hwnd, pitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetItem")] + public static bool TreeView_SetItem(HWND hwnd, ref TVITEM pitem) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SETITEM, default, ref pitem); + + /// + /// The TreeView_SetItem macro sets some or all of a tree-view item's attributes. You can use this macro or send the TVM_SETITEM + /// message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTVITEM + /// + /// Pointer to a TVITEM structure that contains the new item attributes. With version 4.71 and later, you can instead use a TVITEMEX structure. + /// + /// + /// None + /// + /// The hItem member of the TVITEM or TVITEMEX structure identifies the item, and the mask member specifies which + /// attributes to set. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setitem void TreeView_SetItem( hwnd, pitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetItem")] + public static bool TreeView_SetItem(HWND hwnd, ref TVITEMEX pitem) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SETITEM, default, ref pitem); + + /// Sets the height of the tree-view items. You can use this macro or send the TVM_SETITEMHEIGHT message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: SHORT + /// + /// New height of every item in the tree view, in pixels. Heights less than 1 will be set to 1. If this argument is not even, it will be + /// rounded down to the nearest even value. If this argument is -1, the control will revert to using its default item height. + /// + /// + /// None + /// + /// The tree-view control uses this value for the height of all items. To modify the height of individual items, see the description of + /// the iIntegral member of the TVITEMEX structure. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setitemheight void TreeView_SetItemHeight( hwnd, + // iHeight ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetItemHeight")] + public static int TreeView_SetItemHeight(HWND hwnd, short iHeight) => + (int)SendMessage(hwnd, TreeViewMessage.TVM_SETITEMHEIGHT, (IntPtr)(int)iHeight); + + /// Sets a tree-view item's state attributes. You can use this macro or send the TVM_SETITEM message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the item. + /// + /// + /// Type: UINT + /// Value that is equivalent to the state member of . + /// + /// + /// Type: UINT + /// Mask used to select the states to be set. It is equivalent to the stateMask member of TVITEMEX. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setitemstate void TreeView_SetItemState( hwndTV, + // hti, data, _mask ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetItemState")] + public static bool TreeView_SetItemState(HWND hwndTV, HTREEITEM hti, uint data, TreeViewItemStates mask) + { + TVITEM _ms_TVi = new() + { + mask = TreeViewItemMask.TVIF_STATE, + hItem = hti, + stateMask = mask, + state = data + }; + return (BOOL)SendMessage(hwndTV, TreeViewMessage.TVM_SETITEM, default, ref _ms_TVi); + } + + /// Sets the current line color. You can also use the TVM_SETLINECOLOR message directly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: COLORREF + /// A COLORREF that specifies the new line color. Use the CLR_DEFAULT value to restore the system default colors. + /// + /// None + /// + /// This message only changes line colors. To change the colors of the plus sign (+) and minus sign (-) inside the buttons, use the + /// TreeView_SetTextColor macro. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setlinecolor void TreeView_SetLineColor( hwnd, clr ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetLineColor")] + public static COLORREF TreeView_SetLineColor(HWND hwnd, COLORREF clr) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_SETLINECOLOR, default, (IntPtr)clr.ToArgb()); + + /// + /// Sets the maximum scroll time for the tree-view control. You can use this macro or send the TVM_SETSCROLLTIME message explicitly. + /// + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: UINT + /// New maximum scroll time, in milliseconds. If this value is less than 100, it will be rounded up to 100. + /// + /// None + /// + /// The maximum scroll time is the longest amount of time that a scroll operation can take. Scrolling will be adjusted so that the scroll + /// will take place within the maximum scroll time. A scroll operation may take less time than the maximum. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setscrolltime void TreeView_SetScrollTime( hwnd, + // uTime ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetScrollTime")] + public static uint TreeView_SetScrollTime(HWND hwnd, uint uTime) => + (uint)SendMessage(hwnd, TreeViewMessage.TVM_SETSCROLLTIME, (IntPtr)unchecked((int)uTime)); + + /// Sets the text color of the control. You can use this macro or send the TVM_SETTEXTCOLOR message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: COLORREF + /// + /// COLORREF value that contains the new text color. If this argument is -1, the control will revert to using the system color for the + /// text color. + /// + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_settextcolor void TreeView_SetTextColor( hwnd, clr ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetTextColor")] + public static COLORREF TreeView_SetTextColor(HWND hwnd, COLORREF clr) => + (COLORREF)(int)SendMessage(hwnd, TreeViewMessage.TVM_SETTEXTCOLOR, default, (IntPtr)clr.ToArgb()); + + /// Sets a tree-view control's child tooltip control. You can use this macro or send the TVM_SETTOOLTIPS message explicitly. + /// + /// Type: HWND + /// Handle to a tree-view control. + /// + /// + /// Type: HWND + /// Handle to a tooltip control. + /// + /// None + /// + /// When created, tree-view controls automatically create a child tooltip control. To prevent a tree-view control from using tooltips, + /// create the control with the TVS_NOTOOLTIPS style. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_settooltips void TreeView_SetToolTips( hwnd, hwndTT ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetToolTips")] + public static HWND TreeView_SetToolTips(HWND hwnd, HWND hwndTT) => + (HWND)SendMessage(hwnd, TreeViewMessage.TVM_SETTOOLTIPS, (IntPtr)hwndTT); + + /// + /// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the control at + /// run time rather than having to re-create the control. You can use this macro or send the TVM_SETUNICODEFORMAT message explicitly. + /// + /// + /// Type: HWND + /// Handle to the control. + /// + /// + /// Type: BOOL + /// + /// Determines the character set that is used by the control. If this value is nonzero, the control will use Unicode characters. If this + /// value is zero, the control will use ANSI characters. + /// + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_setunicodeformat void TreeView_SetUnicodeFormat( + // hwnd, fUnicode ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SetUnicodeFormat")] + public static bool TreeView_SetUnicodeFormat(HWND hwnd, bool fUnicode) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SETUNICODEFORMAT, fUnicode); + + /// Shows the infotip for a specified item in a tree-view control. Use this macro or send the TVM_SHOWINFOTIP message explicitly. + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HITEM + /// Handle to the item. + /// + /// None + /// + /// Most applications do not use this macro. Infotips are shown automatically. For more information, see Using Tree-view Infotips in the + /// About Tree-View Controls overview. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_showinfotip void TreeView_ShowInfoTip( hwnd, hitem ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_ShowInfoTip")] + public static void TreeView_ShowInfoTip(HWND hwnd, HTREEITEM hitem) => + SendMessage(hwnd, TreeViewMessage.TVM_SHOWINFOTIP, default, (IntPtr)hitem); + + /// + /// Sorts the child items of the specified parent item in a tree-view control. You can use this macro or send the TVM_SORTCHILDREN + /// message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: HTREEITEM + /// Handle to the parent item whose child items are to be sorted. + /// + /// + /// Type: BOOL + /// Not implemented; see remarks. + /// + /// None + /// + /// This message alphabetizes the tree items using lstrcmpi on the item name. You can use the TVM_SORTCHILDRENCB message to customize the + /// ordering behavior. + /// + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_sortchildren void TreeView_SortChildren( hwnd, + // HTREEITEM hitem, recurse ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SortChildren")] + public static bool TreeView_SortChildren(HWND hwnd, HTREEITEM hitem, bool recurse) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SORTCHILDREN, recurse, (IntPtr)hitem); + + /// + /// Sorts tree-view items using an application-defined callback function that compares the items. You can use this macro or send the + /// TVM_SORTCHILDRENCB message explicitly. + /// + /// + /// Type: HWND + /// Handle to the tree-view control. + /// + /// + /// Type: LPTVSORTCB + /// + /// Pointer to a TVSORTCB structure. The lpfnCompare member is the address of the application-defined callback function, which is + /// called during the sort operation each time the relative order of two list items needs to be compared. For more information about the + /// callback function, see the description of TVSORTCB. + /// + /// + /// + /// Type: BOOL + /// Reserved. Must be zero. + /// + /// None + // https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-treeview_sortchildrencb void TreeView_SortChildrenCB( hwnd, + // psort, recurse ); + [PInvokeData("commctrl.h", MSDNShortId = "NF:commctrl.TreeView_SortChildrenCB")] + public static bool TreeView_SortChildrenCB(HWND hwnd, ref TVSORTCB psort, bool recurse) => + (BOOL)SendMessage(hwnd, TreeViewMessage.TVM_SORTCHILDRENCB, recurse, ref psort); + + /// Provides a handle to a tree view item. + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + [StructLayout(LayoutKind.Sequential)] + public readonly struct HTREEITEM(IntPtr preexistingHandle) + { + private readonly IntPtr handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HTREEITEM NULL => new(IntPtr.Zero); @@ -2397,6 +4110,19 @@ public static partial class ComCtl32 /// public override int GetHashCode() => handle.GetHashCode(); + + /// Add the item as a root item. + public static readonly HTREEITEM TVI_ROOT = new((IntPtr)(-65536)); + + /// Inserts the item at the beginning of the list. + public static readonly HTREEITEM TVI_FIRST = new((IntPtr)(-65535)); + + /// Inserts the item at the end of the list. + /// The tvi first + public static readonly HTREEITEM TVI_LAST = new((IntPtr)(-65534)); + + /// Inserts the item into the list in alphabetical order. + public static readonly HTREEITEM TVI_SORT = new((IntPtr)(-65533)); } /// @@ -2417,14 +4143,14 @@ public static partial class ComCtl32 public int action; /// - /// TVITEM structure that contains information about the old item state. This member is zero for notification messages that do - /// not use it. + /// TVITEM structure that contains information about the old item state. This member is zero for notification messages that do not + /// use it. /// public TVITEM itemOld; /// - /// TVITEM structure that contains information about the new item state. This member is zero for notification messages that do - /// not use it. + /// TVITEM structure that contains information about the new item state. This member is zero for notification messages that do not + /// use it. /// public TVITEM itemNew; @@ -2451,8 +4177,8 @@ public static partial class ComCtl32 public IMAGELISTDRAWPARAMS pimldp; /// - /// Result code indicating why the draw failed, either ILDRF_IMAGELOWQUALITY, ILDRF_OVERLAYLOWQUALITY, E_PENDING, or S_OK. A code - /// of S_OK indicates that the image is present but not at the required image quality. + /// Result code indicating why the draw failed, either ILDRF_IMAGELOWQUALITY, ILDRF_OVERLAYLOWQUALITY, E_PENDING, or S_OK. A code of + /// S_OK indicates that the image is present but not at the required image quality. /// public HRESULT hr; @@ -2460,9 +4186,9 @@ public static partial class ComCtl32 public HTREEITEM hItem; /// - /// Data for hItem. This is the same data for the item that is retrieved with the message TVM_GETITEM using the appropriate mask - /// in structure TVITEM. This data is parent specific; the parent can store information that helps it identify the tree item or - /// other information. Data is provided in lParam for convenience, so that the parent does not need to send message TVM_GETITEM. + /// Data for hItem. This is the same data for the item that is retrieved with the message TVM_GETITEM using the appropriate mask in + /// structure TVITEM. This data is parent specific; the parent can store information that helps it identify the tree item or other + /// information. Data is provided in lParam for convenience, so that the parent does not need to send message TVM_GETITEM. /// public IntPtr lParam; @@ -2488,15 +4214,15 @@ public static partial class ComCtl32 public int clrTextBk; /// - /// Version 4.71. Zero-based level of the item being drawn. The root item is at level zero, a child of the root item is at level - /// one, and so on. + /// Version 4.71. Zero-based level of the item being drawn. The root item is at level zero, a child of the root item is at level one, + /// and so on. /// public int iLevel; } /// - /// Contains and receives display information for a tree-view item. This structure is identical to the TV_DISPINFO structure, but it - /// has been renamed to follow current naming conventions. + /// Contains and receives display information for a tree-view item. This structure is identical to the TV_DISPINFO structure, but it has + /// been renamed to follow current naming conventions. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb773418")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] @@ -2536,14 +4262,14 @@ public static partial class ComCtl32 public NMHDR hdr; /// - /// Address of a character buffer that contains the text to be displayed. If you want to change the text displayed in the - /// tooltip, you will need to modify the contents of this buffer. The size of this buffer is specified by the cchTextMax structure. + /// Address of a character buffer that contains the text to be displayed. If you want to change the text displayed in the tooltip, + /// you will need to modify the contents of this buffer. The size of this buffer is specified by the cchTextMax structure. /// public StrPtrAuto pszText; /// - /// Size of the buffer at pszText, in characters. Although you should never assume that this buffer will be of any particular - /// size, the INFOTIPSIZE value can be used for design purposes. + /// Size of the buffer at pszText, in characters. Although you should never assume that this buffer will be of any particular size, + /// the INFOTIPSIZE value can be used for design purposes. /// public int cchTextMax; @@ -2565,8 +4291,8 @@ public static partial class ComCtl32 public NMHDR hdr; /// - /// Specifies the attribute. The only supported attribute is state. uChanged must have the following value: TVIF_STATE = The - /// change is the state attribute. + /// Specifies the attribute. The only supported attribute is state. uChanged must have the following value: TVIF_STATE = The change + /// is the state attribute. /// public TreeViewItemMask uChanged; @@ -2584,8 +4310,8 @@ public static partial class ComCtl32 } /// - /// Contains information about a keyboard event in a tree-view control. This structure is used with the TVN_KEYDOWN notification - /// code. The structure is identical to the TV_KEYDOWN structure, but it has been renamed to follow current naming conventions. + /// Contains information about a keyboard event in a tree-view control. This structure is used with the TVN_KEYDOWN notification code. + /// The structure is identical to the TV_KEYDOWN structure, but it has been renamed to follow current naming conventions. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb773433")] [StructLayout(LayoutKind.Sequential)] @@ -2601,6 +4327,34 @@ public static partial class ComCtl32 public uint flags; } + /// + /// Contains information for identifying the "hit zone" for a specified part of a tree item. The structure is used with the + /// TVM_GETITEMPARTRECT message and the TreeView_GetItemPartRect macro. + /// + /// + /// Initializes a new instance of the class. + /// The h tree node. + [PInvokeData("Commctrl.h", MSDNShortId = "bb773442")] + [StructLayout(LayoutKind.Sequential)] + public struct TVGETITEMPARTRECTINFO(in HTREEITEM hTreeNode) + { + /// Handle to the parent item. + public HTREEITEM hti = hTreeNode; + + /// + /// Pointer to a RECT structure to receive the coordinates of the bounding rectangle. The sender of the message (the caller) is + /// responsible for allocating this structure. + /// + public IntPtr prc; + + /// ID of the item part. This value must be TVGIPR_BUTTON (0x0001). + public TVITEMPART partID = TVITEMPART.TVGIPR_BUTTON; + + /// Gets the bounds. + /// The bounds. + public readonly RECT? Bounds => prc.ToNullableStructure(); + } + /// /// Contains information used to determine the location of a point relative to a tree-view control. This structure is used with the /// TVM_HITTEST message. The structure is identical to the TV_HITTESTINFO structure, but it has been renamed to follow current naming conventions. @@ -2640,8 +4394,8 @@ public static partial class ComCtl32 } /// - /// Specifies or receives attributes of a tree-view item. This structure is identical to the TV_ITEM structure, but it has been - /// renamed to follow current naming conventions. New applications should use this structure. + /// Specifies or receives attributes of a tree-view item. This structure is identical to the TV_ITEM structure, but it has been renamed + /// to follow current naming conventions. New applications should use this structure. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb773456")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] @@ -2649,8 +4403,8 @@ public static partial class ComCtl32 { /// /// Array of flags that indicate which of the other structure members contain valid data. When this structure is used with the - /// TVM_GETITEM message, the mask member indicates the item attributes to retrieve. If used with the TVM_SETITEM message, the - /// mask indicates the attributes to set. + /// TVM_GETITEM message, the mask member indicates the item attributes to retrieve. If used with the TVM_SETITEM message, the mask + /// indicates the attributes to set. /// public TreeViewItemMask mask; @@ -2658,47 +4412,47 @@ public static partial class ComCtl32 public HTREEITEM hItem; /// - /// Set of bit flags and image list indexes that indicate the item's state. When setting the state of an item, the stateMask - /// member indicates the valid bits of this member. When retrieving the state of an item, this member returns the current state - /// for the bits indicated in the stateMask member. + /// Set of bit flags and image list indexes that indicate the item's state. When setting the state of an item, the stateMask member + /// indicates the valid bits of this member. When retrieving the state of an item, this member returns the current state for the bits + /// indicated in the stateMask member. /// public uint state; /// - /// Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to - /// indicate the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask - /// member to indicate the bits of the state member that you want to set. To set or retrieve an item's overlay image index, set - /// the TVIS_OVERLAYMASK bits. To set or retrieve an item's state image index, set the TVIS_STATEIMAGEMASK bits. + /// Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to indicate + /// the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask member to indicate + /// the bits of the state member that you want to set. To set or retrieve an item's overlay image index, set the TVIS_OVERLAYMASK + /// bits. To set or retrieve an item's state image index, set the TVIS_STATEIMAGEMASK bits. /// public TreeViewItemStates stateMask; /// - /// Pointer to a null-terminated string that contains the item text if the structure specifies item attributes. If this member is - /// the LPSTR_TEXTCALLBACK value, the parent window is responsible for storing the name. In this case, the tree-view control - /// sends the parent window a TVN_GETDISPINFO notification code when it needs the item text for displaying, sorting, or editing - /// and a TVN_SETDISPINFO notification code when the item text changes. If the structure is receiving item attributes, this - /// member is the address of the buffer that receives the item text. Note that although the tree-view control allows any length - /// string to be stored as item text, only the first 260 characters are displayed. + /// Pointer to a null-terminated string that contains the item text if the structure specifies item attributes. If this member is the + /// LPSTR_TEXTCALLBACK value, the parent window is responsible for storing the name. In this case, the tree-view control sends the + /// parent window a TVN_GETDISPINFO notification code when it needs the item text for displaying, sorting, or editing and a + /// TVN_SETDISPINFO notification code when the item text changes. If the structure is receiving item attributes, this member is the + /// address of the buffer that receives the item text. Note that although the tree-view control allows any length string to be stored + /// as item text, only the first 260 characters are displayed. /// public IntPtr pszText; /// - /// Size of the buffer pointed to by the pszText member, in characters. If this structure is being used to set item attributes, - /// this member is ignored. + /// Size of the buffer pointed to by the pszText member, in characters. If this structure is being used to set item attributes, this + /// member is ignored. /// public int cchTextMax; /// - /// Index in the tree-view control's image list of the icon image to use when the item is in the nonselected state. If this - /// member is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view - /// control sends the parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. + /// Index in the tree-view control's image list of the icon image to use when the item is in the nonselected state. If this member is + /// the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view control sends the + /// parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. /// public int iImage; /// - /// Index in the tree-view control's image list of the icon image to use when the item is in the selected state. If this member - /// is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view control - /// sends the parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. + /// Index in the tree-view control's image list of the icon image to use when the item is in the selected state. If this member is + /// the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view control sends the + /// parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. /// public int iSelectedImage; @@ -2720,13 +4474,13 @@ public static partial class ComCtl32 /// /// I_CHILDRENCALLBACK /// - /// The parent window keeps track of whether the item has child items.In this case, when the tree-view control needs to display - /// the item, the control sends the parent a TVN_GETDISPINFO notification code to determine whether the item has child items. + /// The parent window keeps track of whether the item has child items.In this case, when the tree-view control needs to display the + /// item, the control sends the parent a TVN_GETDISPINFO notification code to determine whether the item has child items. /// - /// If the tree-view control has the TVS_HASBUTTONS style, it uses this member to determine whether to display the button - /// indicating the presence of child items. You can use this member to force the control to display the button even though the - /// item does not have any child items inserted. This allows you to display the button while minimizing the control's memory - /// usage by inserting child items only when the item is visible or expanded. + /// If the tree-view control has the TVS_HASBUTTONS style, it uses this member to determine whether to display the button indicating + /// the presence of child items. You can use this member to force the control to display the button even though the item does not + /// have any child items inserted. This allows you to display the button while minimizing the control's memory usage by inserting + /// child items only when the item is visible or expanded. /// /// /// @@ -2734,10 +4488,10 @@ public static partial class ComCtl32 /// I_CHILDRENAUTO /// /// Version 6.0 Intended for internal use; not recommended for use in applications.The tree-view control automatically determines - /// whether the item has child items. This flag may not be supported in future versions of Comctl32.dll.Also, this flag is - /// not defined in commctrl.h.Add the following definition to the source files of your application to use the flag: + /// whether the item has child items. This flag may not be supported in future versions of Comctl32.dll.Also, this flag is not + /// defined in commctrl.h.Add the following definition to the source files of your application to use the flag: /// - /// #define I_CHILDRENAUTO (-2) + ///#define I_CHILDRENAUTO (-2) /// /// /// @@ -2752,28 +4506,32 @@ public static partial class ComCtl32 /// true if bold; otherwise, false. public bool Bold { - get => GetState(TreeViewItemStates.TVIS_BOLD); set => SetState(TreeViewItemStates.TVIS_BOLD, value); + readonly get => GetState(TreeViewItemStates.TVIS_BOLD); + set => SetState(TreeViewItemStates.TVIS_BOLD, value); } /// Gets or sets a value indicating whether this is expanded. /// true if expanded; otherwise, false. public bool Expanded { - get => GetState(TreeViewItemStates.TVIS_EXPANDED); set => SetState(TreeViewItemStates.TVIS_EXPANDED, value); + readonly get => GetState(TreeViewItemStates.TVIS_EXPANDED); + set => SetState(TreeViewItemStates.TVIS_EXPANDED, value); } /// Gets or sets a value indicating whether child items have been expanded at least once. /// true if child items have been expanded at least once; otherwise, false. public bool ExpandedOnce { - get => GetState(TreeViewItemStates.TVIS_EXPANDEDONCE); set => SetState(TreeViewItemStates.TVIS_EXPANDEDONCE, value); + readonly get => GetState(TreeViewItemStates.TVIS_EXPANDEDONCE); + set => SetState(TreeViewItemStates.TVIS_EXPANDEDONCE, value); } /// Gets or sets a value indicating whether item is partially expanded. /// true if partially expanded; otherwise, false. public bool ExpandedPartial { - get => GetState(TreeViewItemStates.TVIS_EXPANDPARTIAL); set => SetState(TreeViewItemStates.TVIS_EXPANDPARTIAL, value); + readonly get => GetState(TreeViewItemStates.TVIS_EXPANDPARTIAL); + set => SetState(TreeViewItemStates.TVIS_EXPANDPARTIAL, value); } /// Gets or sets the index of the overlay image. @@ -2781,7 +4539,8 @@ public static partial class ComCtl32 /// OverlayImageIndex - Overlay image index must be between 0 and 15 public uint OverlayImageIndex { - get => (state & 0x00000F00) >> 8; set + readonly get => (state & 0x00000F00) >> 8; + set { if (value > 15) throw new ArgumentOutOfRangeException(nameof(OverlayImageIndex), "Overlay image index must be between 0 and 15"); @@ -2795,33 +4554,36 @@ public static partial class ComCtl32 /// true if selected; otherwise, false. public bool Selected { - get => GetState(TreeViewItemStates.TVIS_SELECTED); set => SetState(TreeViewItemStates.TVIS_SELECTED, value); + readonly get => GetState(TreeViewItemStates.TVIS_SELECTED); + set => SetState(TreeViewItemStates.TVIS_SELECTED, value); } /// Gets or sets a value indicating whether item is selected as part of a cut-and-paste operation. /// true if item is selected as part of a cut-and-paste operation; otherwise, false. public bool SelectedForCut { - get => GetState(TreeViewItemStates.TVIS_CUT); set => SetState(TreeViewItemStates.TVIS_CUT, value); + readonly get => GetState(TreeViewItemStates.TVIS_CUT); + set => SetState(TreeViewItemStates.TVIS_CUT, value); } /// Gets or sets a value indicating whether item is selected as a drag-and-drop target. /// true if item is selected as a drag-and-drop target; otherwise, false. public bool SelectedForDragDrop { - get => GetState(TreeViewItemStates.TVIS_DROPHILITED); set => SetState(TreeViewItemStates.TVIS_DROPHILITED, value); + readonly get => GetState(TreeViewItemStates.TVIS_DROPHILITED); + set => SetState(TreeViewItemStates.TVIS_DROPHILITED, value); } /// Gets the state. /// The state. - public TreeViewItemStates State => (TreeViewItemStates)(state & 0x000000FF); + public readonly TreeViewItemStates State => (TreeViewItemStates)(state & 0x000000FF); /// Gets or sets the index of the state image. /// The index of the state image. /// StateImageIndex - State image index must be between 0 and 15 public uint StateImageIndex { - get => (state & 0x0000F000) >> 12; set + readonly get => (state & 0x0000F000) >> 12; set { if (value > 15) throw new ArgumentOutOfRangeException(nameof(StateImageIndex), "State image index must be between 0 and 15"); @@ -2833,13 +4595,13 @@ public static partial class ComCtl32 /// Gets the text. /// The text. - public string? Text => pszText == LPSTR_TEXTCALLBACK ? null : Marshal.PtrToStringUni(pszText); + public readonly string? Text => pszText == LPSTR_TEXTCALLBACK ? null : Marshal.PtrToStringUni(pszText); /// Gets or sets a value indicating whether to use text callback. /// true if to use text callback; otherwise, false. public bool UseTextCallback { - get => pszText == LPSTR_TEXTCALLBACK; + readonly get => pszText == LPSTR_TEXTCALLBACK; set { if (value) @@ -2851,7 +4613,7 @@ public static partial class ComCtl32 /// Gets a value on whether the specified state is set. /// State of the item. /// true if the specified state is set; otherwise, false. - public bool GetState(TreeViewItemStates itemState) => State.IsFlagSet(itemState); + public readonly bool GetState(TreeViewItemStates itemState) => State.IsFlagSet(itemState); /// Sets the state of the specified state. /// State of the item. @@ -2877,7 +4639,7 @@ public static partial class ComCtl32 /// Returns a that represents this instance. /// A that represents this instance. - public override string ToString() => $"TVITEM: pszText={Text}; iImage={iImage}; iSelectedImage={iSelectedImage}; state={state}; cChildren={cChildren}"; + public override readonly string ToString() => $"TVITEM: pszText={Text}; iImage={iImage}; iSelectedImage={iSelectedImage}; state={state}; cChildren={cChildren}"; } /// @@ -2890,8 +4652,8 @@ public static partial class ComCtl32 { /// /// Array of flags that indicate which of the other structure members contain valid data. When this structure is used with the - /// TVM_GETITEM message, the mask member indicates the item attributes to retrieve. If used with the TVM_SETITEM message, the - /// mask indicates the attributes to set. + /// TVM_GETITEM message, the mask member indicates the item attributes to retrieve. If used with the TVM_SETITEM message, the mask + /// indicates the attributes to set. /// public TreeViewItemMask mask; @@ -2899,47 +4661,47 @@ public static partial class ComCtl32 public HTREEITEM hItem; /// - /// Set of bit flags and image list indexes that indicate the item's state. When setting the state of an item, the stateMask - /// member indicates the valid bits of this member. When retrieving the state of an item, this member returns the current state - /// for the bits indicated in the stateMask member. + /// Set of bit flags and image list indexes that indicate the item's state. When setting the state of an item, the stateMask member + /// indicates the valid bits of this member. When retrieving the state of an item, this member returns the current state for the bits + /// indicated in the stateMask member. /// public uint state; /// - /// Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to - /// indicate the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask - /// member to indicate the bits of the state member that you want to set. To set or retrieve an item's overlay image index, set - /// the TVIS_OVERLAYMASK bits. To set or retrieve an item's state image index, set the TVIS_STATEIMAGEMASK bits. + /// Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to indicate + /// the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask member to indicate + /// the bits of the state member that you want to set. To set or retrieve an item's overlay image index, set the TVIS_OVERLAYMASK + /// bits. To set or retrieve an item's state image index, set the TVIS_STATEIMAGEMASK bits. /// public TreeViewItemStates stateMask; /// - /// Pointer to a null-terminated string that contains the item text if the structure specifies item attributes. If this member is - /// the LPSTR_TEXTCALLBACK value, the parent window is responsible for storing the name. In this case, the tree-view control - /// sends the parent window a TVN_GETDISPINFO notification code when it needs the item text for displaying, sorting, or editing - /// and a TVN_SETDISPINFO notification code when the item text changes. If the structure is receiving item attributes, this - /// member is the address of the buffer that receives the item text. Note that although the tree-view control allows any length - /// string to be stored as item text, only the first 260 characters are displayed. + /// Pointer to a null-terminated string that contains the item text if the structure specifies item attributes. If this member is the + /// LPSTR_TEXTCALLBACK value, the parent window is responsible for storing the name. In this case, the tree-view control sends the + /// parent window a TVN_GETDISPINFO notification code when it needs the item text for displaying, sorting, or editing and a + /// TVN_SETDISPINFO notification code when the item text changes. If the structure is receiving item attributes, this member is the + /// address of the buffer that receives the item text. Note that although the tree-view control allows any length string to be stored + /// as item text, only the first 260 characters are displayed. /// public StrPtrAuto pszText; /// - /// Size of the buffer pointed to by the pszText member, in characters. If this structure is being used to set item attributes, - /// this member is ignored. + /// Size of the buffer pointed to by the pszText member, in characters. If this structure is being used to set item attributes, this + /// member is ignored. /// public int cchTextMax; /// - /// Index in the tree-view control's image list of the icon image to use when the item is in the nonselected state. If this - /// member is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view - /// control sends the parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. + /// Index in the tree-view control's image list of the icon image to use when the item is in the nonselected state. If this member is + /// the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view control sends the + /// parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. /// public int iImage; /// - /// Index in the tree-view control's image list of the icon image to use when the item is in the selected state. If this member - /// is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view control - /// sends the parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. + /// Index in the tree-view control's image list of the icon image to use when the item is in the selected state. If this member is + /// the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree-view control sends the + /// parent a TVN_GETDISPINFO notification code to retrieve the index when it needs to display the image. /// public int iSelectedImage; @@ -2961,13 +4723,13 @@ public static partial class ComCtl32 /// /// I_CHILDRENCALLBACK /// - /// The parent window keeps track of whether the item has child items.In this case, when the tree-view control needs to display - /// the item, the control sends the parent a TVN_GETDISPINFO notification code to determine whether the item has child items. + /// The parent window keeps track of whether the item has child items.In this case, when the tree-view control needs to display the + /// item, the control sends the parent a TVN_GETDISPINFO notification code to determine whether the item has child items. /// - /// If the tree-view control has the TVS_HASBUTTONS style, it uses this member to determine whether to display the button - /// indicating the presence of child items. You can use this member to force the control to display the button even though the - /// item does not have any child items inserted. This allows you to display the button while minimizing the control's memory - /// usage by inserting child items only when the item is visible or expanded. + /// If the tree-view control has the TVS_HASBUTTONS style, it uses this member to determine whether to display the button indicating + /// the presence of child items. You can use this member to force the control to display the button even though the item does not + /// have any child items inserted. This allows you to display the button while minimizing the control's memory usage by inserting + /// child items only when the item is visible or expanded. /// /// /// @@ -2975,10 +4737,10 @@ public static partial class ComCtl32 /// I_CHILDRENAUTO /// /// Version 6.0 Intended for internal use; not recommended for use in applications.The tree-view control automatically determines - /// whether the item has child items. This flag may not be supported in future versions of Comctl32.dll.Also, this flag is - /// not defined in commctrl.h.Add the following definition to the source files of your application to use the flag: + /// whether the item has child items. This flag may not be supported in future versions of Comctl32.dll.Also, this flag is not + /// defined in commctrl.h.Add the following definition to the source files of your application to use the flag: /// - /// #define I_CHILDRENAUTO (-2) + ///#define I_CHILDRENAUTO (-2) /// /// /// @@ -3008,28 +4770,32 @@ public static partial class ComCtl32 /// true if bold; otherwise, false. public bool Bold { - get => GetState(TreeViewItemStates.TVIS_BOLD); set => SetState(TreeViewItemStates.TVIS_BOLD, value); + readonly get => GetState(TreeViewItemStates.TVIS_BOLD); + set => SetState(TreeViewItemStates.TVIS_BOLD, value); } /// Gets or sets a value indicating whether this is expanded. /// true if expanded; otherwise, false. public bool Expanded { - get => GetState(TreeViewItemStates.TVIS_EXPANDED); set => SetState(TreeViewItemStates.TVIS_EXPANDED, value); + readonly get => GetState(TreeViewItemStates.TVIS_EXPANDED); + set => SetState(TreeViewItemStates.TVIS_EXPANDED, value); } /// Gets or sets a value indicating whether child items have been expanded at least once. /// true if child items have been expanded at least once; otherwise, false. public bool ExpandedOnce { - get => GetState(TreeViewItemStates.TVIS_EXPANDEDONCE); set => SetState(TreeViewItemStates.TVIS_EXPANDEDONCE, value); + readonly get => GetState(TreeViewItemStates.TVIS_EXPANDEDONCE); + set => SetState(TreeViewItemStates.TVIS_EXPANDEDONCE, value); } /// Gets or sets a value indicating whether item is partially expanded. /// true if partially expanded; otherwise, false. public bool ExpandedPartial { - get => GetState(TreeViewItemStates.TVIS_EXPANDPARTIAL); set => SetState(TreeViewItemStates.TVIS_EXPANDPARTIAL, value); + readonly get => GetState(TreeViewItemStates.TVIS_EXPANDPARTIAL); + set => SetState(TreeViewItemStates.TVIS_EXPANDPARTIAL, value); } /// Gets or sets the index of the overlay image. @@ -3037,7 +4803,7 @@ public static partial class ComCtl32 /// OverlayImageIndex - Overlay image index must be between 0 and 15 public uint OverlayImageIndex { - get => (state & 0x00000F00) >> 8; set + readonly get => (state & 0x00000F00) >> 8; set { if (value > 15) throw new ArgumentOutOfRangeException(nameof(OverlayImageIndex), "Overlay image index must be between 0 and 15"); @@ -3051,34 +4817,36 @@ public static partial class ComCtl32 /// true if selected; otherwise, false. public bool Selected { - get => GetState(TreeViewItemStates.TVIS_SELECTED); set => SetState(TreeViewItemStates.TVIS_SELECTED, value); + readonly get => GetState(TreeViewItemStates.TVIS_SELECTED); + set => SetState(TreeViewItemStates.TVIS_SELECTED, value); } /// Gets or sets a value indicating whether item is selected as part of a cut-and-paste operation. /// true if item is selected as part of a cut-and-paste operation; otherwise, false. public bool SelectedForCut { - get => GetState(TreeViewItemStates.TVIS_CUT); set => SetState(TreeViewItemStates.TVIS_CUT, value); + readonly get => GetState(TreeViewItemStates.TVIS_CUT); + set => SetState(TreeViewItemStates.TVIS_CUT, value); } /// Gets or sets a value indicating whether item is selected as a drag-and-drop target. /// true if item is selected as a drag-and-drop target; otherwise, false. public bool SelectedForDragDrop { - get => GetState(TreeViewItemStates.TVIS_DROPHILITED); + readonly get => GetState(TreeViewItemStates.TVIS_DROPHILITED); set => SetState(TreeViewItemStates.TVIS_DROPHILITED, value); } /// Gets the state. /// The state. - public TreeViewItemStates State => (TreeViewItemStates)(state & 0x000000FF); + public readonly TreeViewItemStates State => (TreeViewItemStates)(state & 0x000000FF); /// Gets or sets the index of the state image. /// The index of the state image. /// StateImageIndex - State image index must be between 0 and 15 public uint StateImageIndex { - get => (state & 0x0000F000) >> 12; set + readonly get => (state & 0x0000F000) >> 12; set { if (value > 15) throw new ArgumentOutOfRangeException(nameof(StateImageIndex), "State image index must be between 0 and 15"); @@ -3096,7 +4864,7 @@ public static partial class ComCtl32 /// true if to use text callback; otherwise, false. public bool UseTextCallback { - get => (IntPtr)pszText == LPSTR_TEXTCALLBACK; + readonly get => (IntPtr)pszText == LPSTR_TEXTCALLBACK; set { if (value) @@ -3108,7 +4876,7 @@ public static partial class ComCtl32 /// Gets a value on whether the specified state is set. /// State of the item. /// true if the specified state is set; otherwise, false. - public bool GetState(TreeViewItemStates itemState) => State.IsFlagSet(itemState); + public readonly bool GetState(TreeViewItemStates itemState) => State.IsFlagSet(itemState); /// Sets the state of the specified state. /// State of the item. @@ -3149,52 +4917,12 @@ public static partial class ComCtl32 public HTREEITEM hParent; /// - /// Address of an application-defined callback function, which is called during a sort operation each time the relative order of - /// two list items needs to be compared. + /// Address of an application-defined callback function, which is called during a sort operation each time the relative order of two + /// list items needs to be compared. /// public PFNTVCOMPARE lpfnCompare; - /// - /// Application-defined value that gets passed as the lParamSort argument in the callback function specified in lpfnCompare. - /// + /// Application-defined value that gets passed as the lParamSort argument in the callback function specified in lpfnCompare. public IntPtr lParam; } - - /// - /// Contains information for identifying the "hit zone" for a specified part of a tree item. The structure is used with the - /// TVM_GETITEMPARTRECT message and the TreeView_GetItemPartRect macro. - /// - /// - [PInvokeData("Commctrl.h", MSDNShortId = "bb773442")] - [StructLayout(LayoutKind.Sequential)] - public sealed class TVGETITEMPARTRECTINFO : IDisposable - { - /// Handle to the parent item. - public HTREEITEM hti; - - /// - /// Pointer to a RECT structure to receive the coordinates of the bounding rectangle. The sender of the message (the caller) is - /// responsible for allocating this structure. - /// - public IntPtr prc; - - /// ID of the item part. This value must be TVGIPR_BUTTON (0x0001). - public TVITEMPART partID; - - /// Initializes a new instance of the class. - /// The h tree node. - public TVGETITEMPARTRECTINFO(HTREEITEM hTreeNode) - { - hti = hTreeNode; - prc = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(RECT))); - partID = TVITEMPART.TVGIPR_BUTTON; - } - - /// Gets the bounds. - /// The bounds. - public RECT Bounds => prc.ToStructure(); - - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - void IDisposable.Dispose() => Marshal.FreeCoTaskMem(prc); - } } \ No newline at end of file