using System; using System.Runtime.InteropServices; using System.Text; namespace Vanara.PInvoke { public static partial class Shell32 { /// Indicates which button was clicked and the kind of click. [PInvokeData("shobjidl.h", MSDNShortId = "a595ffd0-edc6-4726-b7b2-ad1aed9e9701")] [Flags] public enum NSTCECLICKTYPE { /// The left button was clicked. NSTCECT_LBUTTON = 0x0001, /// The middle button was clicked. NSTCECT_MBUTTON = 0x0002, /// The right button was clicked. NSTCECT_RBUTTON = 0x0003, /// A button was clicked. NSTCECT_BUTTON = 0x0003, /// The click was a double click. If this value is present, it is added to one of the other values. NSTCECT_DBLCLICK = 0x0004, } /// The location on the IShellItem that was clicked. [PInvokeData("shobjidl.h", MSDNShortId = "a595ffd0-edc6-4726-b7b2-ad1aed9e9701")] [Flags] public enum NSTCEHITTEST { /// The click missed the IShellItem. NSTCEHT_NOWHERE = 0x0001, /// The click was on the icon of the IShellItem. NSTCEHT_ONITEMICON = 0x0002, /// The click was on the label text of the IShellItem. NSTCEHT_ONITEMLABEL = 0x0004, /// The click was on the indented space on the leftmost side of the IShellItem. NSTCEHT_ONITEMINDENT = 0x0008, /// The click was on the expando button of the IShellItem. NSTCEHT_ONITEMBUTTON = 0x0010, /// The click was on the rightmost side of the text of the IShellItem. NSTCEHT_ONITEMRIGHT = 0x0020, /// The click was on the state icon of the IShellItem. NSTCEHT_ONITEMSTATEICON = 0x0040, /// The click was on the item icon or the item label or the state icon of the IShellItem. NSTCEHT_ONITEM = 0x0046, /// The click was on the tab button of the IShellItem. NSTCEHT_ONITEMTABBUTTON = 0x1000, }; /// /// Specifies the state of a tree item. These values are used by methods of the INameSpaceTreeControlFolderCapabilities interface. /// /// The NSTCFOLDERCAPABILITIES type is defined in Shobjidl.h beginning in Windows 7. // https://docs.microsoft.com/ja-jp/windows/win32/api/shobjidl_core/ne-shobjidl_core-nstcfoldercapabilities [PInvokeData("shobjidl_core.h", MSDNShortId = "a5282277-85f5-494e-b994-efbf1116b519")] [Flags] public enum NSTCFOLDERCAPABILITIES { /// The property does not exist. Filtering is not supported. NSTCFC_NONE = 0, /// Property exists. Supports filtering based on the value specified in System.IsPinnedToNameSpaceTree. NSTCFC_PINNEDITEMFILTERING = 1, /// Delays registration for change notifications until the tree is expanded in the navigation pane. NSTCFC_DELAY_REGISTER_NOTIFY = 2, } /// The type of the next item. [PInvokeData("shobjidl_core.h", MSDNShortId = "71ede595-14b6-4e59-854a-af75c02093f8")] public enum NSTCGNI { /// The next sibling of the given item. NSTCGNI_NEXT = 0, /// /// The next visible item in the tree that has any relationship to the given item. This includes a child (if there is one), the /// next sibling, or even one of the ancestor's siblings. /// NSTCGNI_NEXTVISIBLE = 1, /// The previous sibling item of the given item. NSTCGNI_PREV = 2, /// The previous visible item that is a sibling item, sibling descendent item or a parent item. NSTCGNI_PREVVISIBLE = 3, /// The parent item of the given item. NSTCGNI_PARENT = 4, /// The first child item of the given item. NSTCGNI_CHILD = 5, /// The absolute first visible item in the tree (not relative to the given item). NSTCGNI_FIRSTVISIBLE = 6, /// The absolute last visible item in the tree (not relative to the given item). NSTCGNI_LASTVISIBLE = 7, } /// Specifies the state of a tree item. These values are used by methods of the INameSpaceTreeControl interface. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_nstcitemstate typedef enum _NSTCITEMSTATE { // NSTCIS_NONE, NSTCIS_SELECTED, NSTCIS_EXPANDED, NSTCIS_BOLD, NSTCIS_DISABLED, NSTCIS_SELECTEDNOEXPAND } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "1f3fd526-c044-41ff-9e05-c6d91d386b42")] [Flags] public enum NSTCITEMSTATE : uint { /// The item has default state; it is not selected, expanded, bolded or disabled. NSTCIS_NONE = 0x0000, /// The item is selected. NSTCIS_SELECTED = 0x0001, /// The item is expanded. NSTCIS_EXPANDED = 0x0002, /// The item is bold. NSTCIS_BOLD = 0x0004, /// The item is disabled. NSTCIS_DISABLED = 0x0008, /// Windows 7 and later. The item is selected, but not expanded. NSTCIS_SELECTEDNOEXPAND = 0x0010, } /// Specifies the style of the root that is being appended. [PInvokeData("shobjidl_core.h", MSDNShortId = "a280d183-9215-43c2-bba3-63c34ba33285")] [Flags] public enum NSTCROOTSTYLE : uint { /// The root is visible as well as the items. Mutually exclusive with NSTCRS_HIDDEN. NSTCRS_VISIBLE = 0x0000, /// The root is hidden so that the children only are visible. Mutually exclusive with NSTCRS_VISIBLE. NSTCRS_HIDDEN = 0x0001, /// The root is expanded upon initialization. NSTCRS_EXPANDED = 0x0002, } /// Describes the characteristics of a given namespace tree control. /// /// /// Three values have effect only in conjunction with NSTCS_CHECKBOXES: NSTCS_PARTIALCHECKBOXES, NSTCS_EXCLUSIONCHECKBOXES, and /// NSTCS_DIMMEDCHECKBOXES. The icons associated with these states are inserted into the state image list as follows: /// /// /// /// Image Slot /// Image /// Associated Flags /// /// /// 0 /// Blank /// NSTCS_CHECKBOXES /// /// /// 1 /// Unchecked /// NSTCS_CHECKBOXES /// /// /// 2 /// Checked /// NSTCS_CHECKBOXES /// /// /// 3 /// Partial /// NSTCS_CHECKBOXES | NSTCS_PARTIALCHECKBOXES /// /// /// 4 /// Exclusion (red X) /// NSTCS_CHECKBOXES | NSTCS_EXCLUSIONCHECKBOXES /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_nstcstyle typedef enum _NSTCSTYLE { // NSTCS_HASEXPANDOS, NSTCS_HASLINES, NSTCS_SINGLECLICKEXPAND, NSTCS_FULLROWSELECT, NSTCS_SPRINGEXPAND, NSTCS_HORIZONTALSCROLL, // NSTCS_ROOTHASEXPANDO, NSTCS_SHOWSELECTIONALWAYS, NSTCS_NOINFOTIP, NSTCS_EVENHEIGHT, NSTCS_NOREPLACEOPEN, NSTCS_DISABLEDRAGDROP, // NSTCS_NOORDERSTREAM, NSTCS_RICHTOOLTIP, NSTCS_BORDER, NSTCS_NOEDITLABELS, NSTCS_TABSTOP, NSTCS_FAVORITESMODE, NSTCS_AUTOHSCROLL, // NSTCS_FADEINOUTEXPANDOS, NSTCS_EMPTYTEXT, NSTCS_CHECKBOXES, NSTCS_PARTIALCHECKBOXES, NSTCS_EXCLUSIONCHECKBOXES, // NSTCS_DIMMEDCHECKBOXES, NSTCS_NOINDENTCHECKS, NSTCS_ALLOWJUNCTIONS, NSTCS_SHOWTABSBUTTON, NSTCS_SHOWDELETEBUTTON, // NSTCS_SHOWREFRESHBUTTON } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "879af1be-2eea-4ebd-b9ea-64b1db40682d")] [Flags] public enum NSTCSTYLE : uint { /// /// The control displays a triangle—known as an expando—on the leftmost edge of those items that have child items. Clicking on /// the expando expands the item to reveal the children of the item. Has no effect when combined with NSTCS_SHOWTABSBUTTON, /// NSTCS_SHOWDELETEBUTTON, or NSTCS_SHOWREFRESHBUTTON. Maps to the TVS_HASBUTTONS tree view control style. /// NSTCS_HASEXPANDOS = 0x00000001, /// /// The control draws lines to the left of the tree items that lead to their individual parent items. Has no effect when /// combined with NSTCS_SHOWTABSBUTTON, NSTCS_SHOWDELETEBUTTON, or NSTCS_SHOWREFRESHBUTTON. Maps to the TVS_HASLINES tree view /// control style. /// NSTCS_HASLINES = 0x00000002, /// /// An item expands to show its child items in response to a single mouse click. Maps to the TVS_SINGLEEXPAND tree view control style. /// NSTCS_SINGLECLICKEXPAND = 0x00000004, /// /// The selection of an item fills the row with inverse text to the end of the window area, regardless of the length of the /// text. When this option is not declared, only the area behind text is inverted. This value cannot be combined with /// NSTCS_HASLINES. Maps to the TVS_FULLROWSELECT tree view control style. /// NSTCS_FULLROWSELECT = 0x00000008, /// /// When one item is selected and expanded and you select a second item, the first selection automatically collapses. This is /// the opposite of the TVS_EX_NOSINGLECOLLAPSE tree view control style. /// NSTCS_SPRINGEXPAND = 0x00000010, /// /// The area of the window that contains the tree of namespace items has a horizontal scroll bar. Maps to the WS_HSCROLL Windows style. /// NSTCS_HORIZONTALSCROLL = 0x00000020, /// /// The root item is preceded by an expando that allows expansion of the root item. Maps to the TVS_LINESATROOT tree view /// control style. /// NSTCS_ROOTHASEXPANDO = 0x00000040, /// /// The node of an item is outlined when the control does not have the focus. Maps to the TVS_SHOWSELALWAYS tree view control style. /// NSTCS_SHOWSELECTIONALWAYS = 0x00000080, /// /// Do not display infotips when the mouse cursor is over an item. This is the opposite of the TVS_INFOTIP tree view control style. /// NSTCS_NOINFOTIP = 0x00000200, /// /// Sets the height of the items to an even height. By default, the height of items can be even or odd. This is the opposite of /// the TVS_NONEVENHEIGHT tree view control style. /// NSTCS_EVENHEIGHT = 0x00000400, /// Do not replace the Open command in the shortcut menu with a user-defined function. NSTCS_NOREPLACEOPEN = 0x00000800, /// /// Do not allow drag-and-drop operations within the control. Note that you can still drag an item from outside of the control /// and drop it onto the control. Maps to the TVS_DISABLEDRAGDROP tree view control style. /// NSTCS_DISABLEDRAGDROP = 0x00001000, /// /// Do not persist reordering changes. Used with NSTCS_FAVORITESMODE. If favorites mode is not specified, this flag has no effect. /// NSTCS_NOORDERSTREAM = 0x00002000, /// /// Use a rich tooltip. Rich tooltips display the item's icon in addition to the item's text. A standard tooltip displays only /// the item's text. The tree view displays tooltips only for items in the tree that are partially visible. Maps to the /// TVS_EX_RICHTOOLTIP tree view control style.NSTCS_RICHTOOLTIP has no effect unless it is combined with NSTCS_NOINFOTIP and/or /// NSTCS_FAVORITESMODE. If NSTCS_NOINFOTIP is not specified, the tree view displays an infotip instead of a tooltip. If /// NSTCS_FAVORITESMODE is not specified, the namespace tree control always sets the TVS_EX_RICHTOOLTIP style. /// NSTCS_RICHTOOLTIP = 0x00004000, /// Draw a thin border around the control. Corresponds to WS_BORDER. NSTCS_BORDER = 0x00008000, /// /// Do not allow creation of an in-place edit box, which would allow the user to rename the given item. This is the opposite of /// the TVS_EDITLABELS tree view control style. /// NSTCS_NOEDITLABELS = 0x00010000, /// If the control is hosted, you can tabstop into the control. Corresponds to WS_EX_CONTROLPARENT. NSTCS_TABSTOP = 0x00020000, /// The control has the appearance of the favorites band in Windows XP. NSTCS_FAVORITESMODE = 0x00080000, /// /// When you hover the mouse pointer over an item that extends past the end of the control window, the control automatically /// scrolls horizontally so that the item appears more fully in the window area. Maps to the TVS_EX_AUTOHSCROLL tree view /// control style. /// NSTCS_AUTOHSCROLL = 0x00100000, /// /// If the control does not have the focus and there are items that are preceded by expandos, then these expandos are visible /// only when the mouse pointer is near to the control. Maps to the TVS_EX_FADEINOUTEXPANDOS tree view control style. /// NSTCS_FADEINOUTEXPANDOS = 0x00200000, /// /// If an item has no children and is not expanded, then that item contains a line of text at the child level that says "empty". /// NSTCS_EMPTYTEXT = 0x00400000, /// /// Items have check boxes on their leftmost side. These check boxes can be of types partial, exclusion or dimmed, which /// correspond to the flags NSTCS_PARTIALCHECKBOXES, NSTCS_EXCLUSIONCHECKBOXES, and NSTCS_DIMMEDCHECKBOXES. Maps to the /// TVS_CHECKBOXES tree view control style. /// NSTCS_CHECKBOXES = 0x00800000, /// /// Adds a checkbox icon on the leftmost side of a given item with a square in the center, that indicates that the node is /// partially selected. Must be combined with NSTCS_CHECKBOXES. Maps to the TVS_EX_PARTIALCHECKBOXES tree view control style. /// NSTCS_PARTIALCHECKBOXES = 0x01000000, /// /// Adds a checkbox icon on the leftmost side of a given item that contains a red X, which indicates that the item is excluded /// from the current selection. Without this exclusion icon, selection of a parent item includes selection of its child items. /// Must be combined with NSTCS_CHECKBOXES. Maps to the TVS_EX_EXCLUSIONCHECKBOXES tree view control style. /// NSTCS_EXCLUSIONCHECKBOXES = 0x02000000, /// /// Adds a checkbox on the leftmost side of a given item that contains an icon of a dimmed check mark, that indicates that a /// node is selected because its parent is selected. Must be combined with NSTCS_CHECKBOXES. Maps to the TVS_EX_DIMMEDCHECKBOXES /// tree view control style. /// NSTCS_DIMMEDCHECKBOXES = 0x04000000, /// /// Check boxes are located at the far left edge of the window area instead of being indented. Maps to the TVS_EX_NOINDENTSTATE /// tree view control style. /// NSTCS_NOINDENTCHECKS = 0x08000000, /// /// Allow junctions. A junction point, or just junction, is a root of a namespace extension that is normally displayed by /// Windows Explorer as a folder in both tree and folder views. For Windows Explorer to display your extension's files and /// subfolders, you must specify where the root folder is located in the Shell namespace hierarchy. Junctions exist in the file /// system as files, but are not treated as files. An example is a compressed file with a .zip file name extension, which to the /// file system is just a file. However, if this file is treated as a junction, it can represent an entire namespace. This /// allows the namespace tree control to treat compressed files and similar junctions as folders rather than as files. /// NSTCS_ALLOWJUNCTIONS = 0x10000000, /// /// Displays an arrow on the right side of an item if the item is a folder. The action associated with the arrow is /// implementation specific. Cannot be combined with NSTCS_SHOWDELETEBUTTON or NSTCS_SHOWREFRESHBUTTON. /// NSTCS_SHOWTABSBUTTON = 0x20000000, /// /// Displays a red X on the right side of an item. The action associated with the X is implementation specific. Cannot be /// combined with NSTCS_SHOWTABSBUTTON or NSTCS_SHOWREFRESHBUTTON. /// NSTCS_SHOWDELETEBUTTON = 0x40000000, /// /// Displays a refresh button on the right side of an item. The action associated with the button is implementation specific. /// Cannot be combined with NSTCS_SHOWTABSBUTTON or NSTCS_SHOWDELETEBUTTON. /// NSTCS_SHOWREFRESHBUTTON = 0x80000000, } /// Used by methods of the INameSpaceTreeControl2 to specify extended display styles in a Shell namespace treeview. /// /// The value NSTCS2_ALLMASK can be used to mask for the NSTCS2_INTERRUPTNOTIFICATIONS, NSTCS2_SHOWNULLSPACEMENU, and /// NSTCS2_DISPLAYPADDING values. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/ne-shobjidl-nstcstyle2 typedef enum NSTCSTYLE2 { NSTCS2_DEFAULT, // NSTCS2_INTERRUPTNOTIFICATIONS, NSTCS2_SHOWNULLSPACEMENU, NSTCS2_DISPLAYPADDING, NSTCS2_DISPLAYPINNEDONLY, // NTSCS2_NOSINGLETONAUTOEXPAND, NTSCS2_NEVERINSERTNONENUMERATED } ; [PInvokeData("shobjidl.h", MSDNShortId = "0bfa6900-71c0-44b7-8157-662bee58e6c9")] [Flags] public enum NSTCSTYLE2 { /// Displays the tree nodes in default mode, which includes none of the following values. NSTCS2_DEFAULT = 0x00000000, /// Displays interrupt notifications. NSTCS2_INTERRUPTNOTIFICATIONS = 0x00000001, /// Displays the context menu in the padding space. NSTCS2_SHOWNULLSPACEMENU = 0x00000002, /// Inserts spacing (padding) between top-level nodes. NSTCS2_DISPLAYPADDING = 0x00000004, /// /// Filters items based on the System.IsPinnedToNameSpaceTree value when INameSpaceTreeControlFolderCapabilities is implemented. /// NSTCS2_DISPLAYPINNEDONLY = 0x00000008, /// NTSCS2_NOSINGLETONAUTOEXPAND = 0x00000010, /// Do not insert nonenumerated (SFGAO_NONENUMERATED) items in the tree. NTSCS2_NEVERINSERTNONENUMERATED = 0x00000020, } /// Exposes methods that perform accessibility actions on a Shell item from a namespace tree control. /// This interface is used only by INameSpaceTreeControl (CLSID_NameSpaceTreeControl). // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-inamespacetreeaccessible [PInvokeData("shobjidl.h", MSDNShortId = "b14dfe40-e21a-4208-835f-e0febef60783")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("71f312de-43ed-4190-8477-e9536b82350b"), CoClass(typeof(NameSpaceTreeControl))] public interface INameSpaceTreeAccessible { /// Gets the default accessibility action for a Shell item. /// /// Type: IShellItem* /// Pointer to the IShellItem. /// /// /// Type: BSTR* /// When this method returns, contains a BSTR that specifies the default, accessibility action. /// /// /// Type: HRESULT /// Returns S_OK if successful, or E_OUTOFMEMORY otherwise. /// /// This method is called when the default accessibililty action for a Shell item is retrieved. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreeaccessible-ongetdefaultaccessibilityaction // HRESULT OnGetDefaultAccessibilityAction( IShellItem *psi, BSTR *pbstrDefaultAction ); [PreserveSig] HRESULT OnGetDefaultAccessibilityAction([In] IShellItem psi, [MarshalAs(UnmanagedType.BStr)] out string pbstrDefaultAction); /// Invokes the default accessibility action on a Shell item. /// /// Type: IShellItem* /// Pointer to the IShellItem. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreeaccessible-ondodefaultaccessibilityaction // HRESULT OnDoDefaultAccessibilityAction( IShellItem *psi ); [PreserveSig] HRESULT OnDoDefaultAccessibilityAction([In] IShellItem psi); /// Gets the accessibility role for a Shell item. /// /// Type: IShellItem* /// Pointer to the IShellItem. /// /// /// Type: VARIANT* /// When this method returns, contains a VARIANT that specifies the role. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// This method is called when the accessibility role for a Shell item is retrieved. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreeaccessible-ongetaccessibilityrole // HRESULT OnGetAccessibilityRole( IShellItem *psi, VARIANT *pvarRole ); [PreserveSig] HRESULT OnGetAccessibilityRole([In] IShellItem psi, out object pvarRole); } /// Exposes methods used to view and manipulate nodes in a tree of Shell items. /// To implement this interface use class ID CLSID_NameSpaceTreeControl. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-inamespacetreecontrol [PInvokeData("shobjidl_core.h", MSDNShortId = "2072cb3c-e540-4708-bfe8-33fff3a190bd")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("028212A3-B627-47e9-8856-C14265554E4F"), CoClass(typeof(NameSpaceTreeControl))] public interface INameSpaceTreeControl { /// Initializes an INameSpaceTreeControl object. /// /// Type: HWND /// The handle of the parent window. /// /// /// Type: RECT* /// A pointer to a RECT structure that describes the size and position of the control in the client window. /// /// /// Type: NSTCSTYLE /// The characteristics of the given namespace tree control. One or more of the following values from the NSTCSTYLE enumeration. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-initialize HRESULT // Initialize( HWND hwndParent, RECT *prc, NSTCSTYLE nsctsFlags ); [PreserveSig] HRESULT Initialize(HWND hwndParent, in RECT prc, NSTCSTYLE nsctsFlags); /// Enables a client to register with the control. /// /// Type: IUnknown* /// A pointer to the client IUnknown that registers with the control. /// /// /// Type: DWORD* /// A pointer to the cookie that is passed back for registration. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// The pointer to the cookie that is passed back is used to unregister the control later with INameSpaceTreeControl::TreeUnadvise. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-treeadvise HRESULT // TreeAdvise( IUnknown *punk, DWORD *pdwCookie ); [PreserveSig] HRESULT TreeAdvise([MarshalAs(UnmanagedType.IUnknown)] object punk, out uint pdwCookie); /// Enables a client to unregister with the control. /// /// Type: DWORD* /// A pointer to the cookie that is to be unregistered. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// The pointer to the cookie that is passed in is the one that was passed back in INameSpaceTreeControl::TreeAdvise. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-treeunadvise HRESULT // TreeUnadvise( DWORD dwCookie ); [PreserveSig] HRESULT TreeUnadvise(uint dwCookie); /// Appends a Shell item to the list of roots in a tree. /// /// Type: IShellItem* /// Pointer to the Shell item that is being appended. /// /// /// Type: SHCONTF /// /// Enumerates the qualities of the root and all of its children. One or more of the values of type SHCONTF. These flags can be /// combined using a bitwise OR. /// /// /// /// Type: NSTCROOTSTYLE /// Specifies the style of the root that is being appended. One or more of the following values: /// NSTCRS_VISIBLE (0x0000) /// The root is visible as well as the items. Mutually exclusive with NSTCRS_HIDDEN. /// NSTCRS_HIDDEN (0x0001) /// The root is hidden so that the children only are visible. Mutually exclusive with NSTCRS_VISIBLE. /// NSTCRS_EXPANDED (0x0002) /// The root is expanded upon initialization. /// /// /// Type: IShellItemFilter* /// /// Pointer to the IShellItemFilter that enables you to filter which items in the tree are displayed. If supplied, every item is /// customizable with a SHCONTF flag. This value can be NULL if no filter is required. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-appendroot HRESULT // AppendRoot( IShellItem *psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, IShellItemFilter *pif ); [PreserveSig] HRESULT AppendRoot(IShellItem psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, [In, Optional] IShellItemFilter pif); /// Inserts a Shell item on a root item in a tree. /// /// Type: int /// The index at which to insert the root. /// /// /// Type: IShellItem* /// A pointer to the Shell item that is being inserted. /// /// /// Type: SHCONTF /// Enumerates the qualities of the root and all of its children. One of the values of type SHCONTF. /// /// /// Type: NSTCROOTSTYLE /// /// The style of the root that is being inserted. One or more of the following values (flags can be combined using a bitwise OR). /// /// NSTCRS_VISIBLE (0x0000) /// The root is visible as well as the items. Mutually exclusive with NSTCRS_HIDDEN. /// NSTCRS_HIDDEN (0x0001) /// The root is hidden so that only the children are visible. Mutually exclusive with NSTCRS_VISIBLE. /// NSTCRS_EXPANDED (0x0002) /// The root is expanded upon initialization. /// /// /// Type: IShellItemFilter* /// /// A pointer to the IShellItemFilter that enables you to filter which items in the tree are displayed. If supplied, every item /// is customizable with a SHCONTF flag. This value can be NULL if no filter is required. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-insertroot HRESULT // InsertRoot( int iIndex, IShellItem *psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, IShellItemFilter *pif ); [PreserveSig] HRESULT InsertRoot(int iIndex, IShellItem psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, [In, Optional] IShellItemFilter pif); /// Removes a root and its children from a tree. /// /// Type: IShellItem* /// A pointer to the root that is to be removed. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-removeroot HRESULT // RemoveRoot( IShellItem *psiRoot ); [PreserveSig] HRESULT RemoveRoot(IShellItem psiRoot); /// Removes all roots and their children from a tree. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-removeallroots // HRESULT RemoveAllRoots(); [PreserveSig] HRESULT RemoveAllRoots(); /// Gets an array of the root items. /// /// Type: IShellItemArray** /// A pointer to an array of root items. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getrootitems HRESULT // GetRootItems( IShellItemArray **ppsiaRootItems ); [PreserveSig] HRESULT GetRootItems(out IShellItemArray ppsiaRootItems); /// Sets state information for a Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item for which to set the state. /// /// /// Type: NSTCITEMSTATE /// Specifies which information is being set, in the form of a bitmap. One or more of the NSTCITEMSTATE constants. /// /// /// Type: NSTCITEMSTATE /// A bitmap that contains the values to set for the flags specified in nstcisMask. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The nstcisMask value specifies which bits in the value pointed to by pnstcisFlags are to be set. Other bits are ignored. As /// a simple example, if nstcisMask=NSTCIS_SELECTED, then the first bit in the nstcisFlags value determines whether that flag is /// set (1) or removed (0). /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-setitemstate HRESULT // SetItemState( IShellItem *psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisFlags ); [PreserveSig] HRESULT SetItemState(IShellItem psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisFlags); /// Gets state information about a Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item from which to retrieve the state. /// /// /// Type: NSTCITEMSTATE /// Specifies which information is being requested, in the form of a bitmap. One or more of the NSTCITEMSTATE constants. /// /// /// Type: NSTCITEMSTATE* /// When this method returns, points to a bitmap that contains the values requested in nstcisMask. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The nstcisMask value specifies which bits in the value pointed to by pnstcisFlags are requested. As a simple example, if /// nstcisMask=NSTCIS_SELECTED, then only the first bit in the value pointed to by pnstcisFlags is valid when this method /// returns. If the first bit in the value pointed to by pnstcisFlags is 1, then the NSTCIS_SELECTED flag is set. If the first /// bit in the value pointed to by pnstcisFlags is 0, then the NSTCIS_SELECTED flag is not set. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getitemstate HRESULT // GetItemState( IShellItem *psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE *pnstcisFlags ); [PreserveSig] HRESULT GetItemState(IShellItem psi, NSTCITEMSTATE nstcisMask, out NSTCITEMSTATE pnstcisFlags); /// Gets an array of selected Shell items. /// /// Type: IShellItemArray** /// A pointer to an array of selected Shell items. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getselecteditems // HRESULT GetSelectedItems( IShellItemArray **psiaItems ); [PreserveSig] HRESULT GetSelectedItems(out IShellItemArray psiaItems); /// Gets the state of the checkbox associated with a given Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item for which checkbox state is being retrieved. /// /// /// Type: int* /// A pointer to the state of the checkbox for the Shell item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getitemcustomstate // HRESULT GetItemCustomState( IShellItem *psi, int *piStateNumber ); [PreserveSig] HRESULT GetItemCustomState(IShellItem psi, out int piStateNumber); /// Sets the state of the checkbox associated with the Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item for which checkbox state is being set. /// /// /// Type: int /// The desired state of the checkbox for the Shell item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-setitemcustomstate // HRESULT SetItemCustomState( IShellItem *psi, int iStateNumber ); [PreserveSig] HRESULT SetItemCustomState(IShellItem psi, int iStateNumber); /// Ensures that the given item is visible. /// /// Type: IShellItem* /// A pointer to the Shell item for which the visibility is being ensured. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-ensureitemvisible // HRESULT EnsureItemVisible( IShellItem *psi ); [PreserveSig] HRESULT EnsureItemVisible(IShellItem psi); /// Sets the desktop theme for the current window only. /// /// Type: LPCWSTR /// The name of the desktop theme to which the current window is being set. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-settheme HRESULT // SetTheme( LPCWSTR pszTheme ); [PreserveSig] HRESULT SetTheme([MarshalAs(UnmanagedType.LPWStr)] string pszTheme); /// Retrieves the next item in the tree according to which method is requested. /// /// Type: IShellItem* /// The Shell item for which the next item is being retrieved. This value can be NULL. /// /// /// Type: NSTCGNI /// The type of the next item. This value can be one of the following flags: /// NSTCGNI_NEXT (0) /// The next sibling of the given item. /// NSTCGNI_NEXTVISIBLE (1) /// /// The next visible item in the tree that has any relationship to the given item. This includes a child (if there is one), the /// next sibling, or even one of the ancestor's siblings. /// /// NSTCGNI_PREV (2) /// The previous sibling item of the given item. /// NSTCGNI_PREVVISIBLE (3) /// The previous visible item that is a sibling item, sibling descendent item or a parent item. /// NSTCGNI_PARENT (4) /// The parent item of the given item. /// NSTCGNI_CHILD (5) /// The first child item of the given item. /// NSTCGNI_FIRSTVISIBLE (6) /// The absolute first visible item in the tree (not relative to the given item). /// NSTCGNI_LASTVISIBLE (7) /// The absolute last visible item in the tree (not relative to the given item). /// /// /// Type: IShellItem** /// The address of a pointer to the IShellItem that fits the criteria for the next item that was requested. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// If there is no next item for the type selected, this function returns E_FAIL with NULL for the returned item, ppsiNext. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getnextitem HRESULT // GetNextItem( IShellItem *psi, NSTCGNI nstcgi, IShellItem **ppsiNext ); [PreserveSig] HRESULT GetNextItem([In] IShellItem psi, NSTCGNI nstcgi, out IShellItem ppsiNext); /// Retrieves the item that a given point is in, if any. /// /// Type: POINT* /// A pointer to the point to be tested. /// /// /// Type: IShellItem** /// The address of a pointer to the item in which the point exists, or NULL if the point does not exist in an item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// This function returns S_FALSE with a NULL item if the point does not exist in an item. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-hittest HRESULT // HitTest( POINT *ppt, IShellItem **ppsiOut ); [PreserveSig] HRESULT HitTest(in POINT ppt, out IShellItem ppsiOut); /// Gets the RECT structure that describes the size and position of a given item. /// /// Type: IShellItem* /// A pointer to the item for which the RECT structure is being retrieved. /// /// /// Type: RECT* /// A pointer to the RECT structure that describes the size and position of the item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getitemrect HRESULT // GetItemRect( IShellItem *psi, RECT *prect ); [PreserveSig] HRESULT GetItemRect(IShellItem psi, out RECT prect); /// Collapses all of the items in the given tree. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-collapseall HRESULT CollapseAll(); [PreserveSig] HRESULT CollapseAll(); } /// /// Extends the INameSpaceTreeControl interface by providing methods that get and set the display styles of treeview controls for /// use with Shell namespace items. /// /// /// This interface also provides the methods of the INameSpaceTreeControl interface, from which it inherits. /// Use class identifier (CLSID) CLSID_NameSpaceTreeControl to instantiate an instance of this interface. /// When to Implement /// An implementation of this interface is provided with Windows. Third parties should not implement their own versions. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-inamespacetreecontrol2 [PInvokeData("shobjidl.h", MSDNShortId = "5f9514db-35fe-44c7-9324-d69022628913")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("7cc7aed8-290e-49bc-8945-c1401cc9306c"), CoClass(typeof(NameSpaceTreeControl))] public interface INameSpaceTreeControl2 : INameSpaceTreeControl { /// Initializes an INameSpaceTreeControl object. /// /// Type: HWND /// The handle of the parent window. /// /// /// Type: RECT* /// A pointer to a RECT structure that describes the size and position of the control in the client window. /// /// /// Type: NSTCSTYLE /// The characteristics of the given namespace tree control. One or more of the following values from the NSTCSTYLE enumeration. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-initialize HRESULT // Initialize( HWND hwndParent, RECT *prc, NSTCSTYLE nsctsFlags ); [PreserveSig] new HRESULT Initialize(HWND hwndParent, in RECT prc, NSTCSTYLE nsctsFlags); /// Enables a client to register with the control. /// /// Type: IUnknown* /// A pointer to the client IUnknown that registers with the control. /// /// /// Type: DWORD* /// A pointer to the cookie that is passed back for registration. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// The pointer to the cookie that is passed back is used to unregister the control later with INameSpaceTreeControl::TreeUnadvise. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-treeadvise HRESULT // TreeAdvise( IUnknown *punk, DWORD *pdwCookie ); [PreserveSig] new HRESULT TreeAdvise([MarshalAs(UnmanagedType.IUnknown)] object punk, out uint pdwCookie); /// Enables a client to unregister with the control. /// /// Type: DWORD* /// A pointer to the cookie that is to be unregistered. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// The pointer to the cookie that is passed in is the one that was passed back in INameSpaceTreeControl::TreeAdvise. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-treeunadvise HRESULT // TreeUnadvise( DWORD dwCookie ); [PreserveSig] new HRESULT TreeUnadvise(uint dwCookie); /// Appends a Shell item to the list of roots in a tree. /// /// Type: IShellItem* /// Pointer to the Shell item that is being appended. /// /// /// Type: SHCONTF /// /// Enumerates the qualities of the root and all of its children. One or more of the values of type SHCONTF. These flags can be /// combined using a bitwise OR. /// /// /// /// Type: NSTCROOTSTYLE /// Specifies the style of the root that is being appended. One or more of the following values: /// NSTCRS_VISIBLE (0x0000) /// The root is visible as well as the items. Mutually exclusive with NSTCRS_HIDDEN. /// NSTCRS_HIDDEN (0x0001) /// The root is hidden so that the children only are visible. Mutually exclusive with NSTCRS_VISIBLE. /// NSTCRS_EXPANDED (0x0002) /// The root is expanded upon initialization. /// /// /// Type: IShellItemFilter* /// /// Pointer to the IShellItemFilter that enables you to filter which items in the tree are displayed. If supplied, every item is /// customizable with a SHCONTF flag. This value can be NULL if no filter is required. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-appendroot HRESULT // AppendRoot( IShellItem *psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, IShellItemFilter *pif ); [PreserveSig] new HRESULT AppendRoot(IShellItem psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, [In] IShellItemFilter pif); /// Inserts a Shell item on a root item in a tree. /// /// Type: int /// The index at which to insert the root. /// /// /// Type: IShellItem* /// A pointer to the Shell item that is being inserted. /// /// /// Type: SHCONTF /// Enumerates the qualities of the root and all of its children. One of the values of type SHCONTF. /// /// /// Type: NSTCROOTSTYLE /// /// The style of the root that is being inserted. One or more of the following values (flags can be combined using a bitwise OR). /// /// NSTCRS_VISIBLE (0x0000) /// The root is visible as well as the items. Mutually exclusive with NSTCRS_HIDDEN. /// NSTCRS_HIDDEN (0x0001) /// The root is hidden so that only the children are visible. Mutually exclusive with NSTCRS_VISIBLE. /// NSTCRS_EXPANDED (0x0002) /// The root is expanded upon initialization. /// /// /// Type: IShellItemFilter* /// /// A pointer to the IShellItemFilter that enables you to filter which items in the tree are displayed. If supplied, every item /// is customizable with a SHCONTF flag. This value can be NULL if no filter is required. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-insertroot HRESULT // InsertRoot( int iIndex, IShellItem *psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, IShellItemFilter *pif ); [PreserveSig] new HRESULT InsertRoot(int iIndex, IShellItem psiRoot, SHCONTF grfEnumFlags, NSTCROOTSTYLE grfRootStyle, [In] IShellItemFilter pif); /// Removes a root and its children from a tree. /// /// Type: IShellItem* /// A pointer to the root that is to be removed. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-removeroot HRESULT // RemoveRoot( IShellItem *psiRoot ); [PreserveSig] new HRESULT RemoveRoot(IShellItem psiRoot); /// Removes all roots and their children from a tree. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-removeallroots // HRESULT RemoveAllRoots(); [PreserveSig] new HRESULT RemoveAllRoots(); /// Gets an array of the root items. /// /// Type: IShellItemArray** /// A pointer to an array of root items. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getrootitems HRESULT // GetRootItems( IShellItemArray **ppsiaRootItems ); [PreserveSig] new HRESULT GetRootItems(out IShellItemArray ppsiaRootItems); /// Sets state information for a Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item for which to set the state. /// /// /// Type: NSTCITEMSTATE /// Specifies which information is being set, in the form of a bitmap. One or more of the NSTCITEMSTATE constants. /// /// /// Type: NSTCITEMSTATE /// A bitmap that contains the values to set for the flags specified in nstcisMask. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The nstcisMask value specifies which bits in the value pointed to by pnstcisFlags are to be set. Other bits are ignored. As /// a simple example, if nstcisMask=NSTCIS_SELECTED, then the first bit in the nstcisFlags value determines whether that flag is /// set (1) or removed (0). /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-setitemstate HRESULT // SetItemState( IShellItem *psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisFlags ); [PreserveSig] new HRESULT SetItemState(IShellItem psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisFlags); /// Gets state information about a Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item from which to retrieve the state. /// /// /// Type: NSTCITEMSTATE /// Specifies which information is being requested, in the form of a bitmap. One or more of the NSTCITEMSTATE constants. /// /// /// Type: NSTCITEMSTATE* /// When this method returns, points to a bitmap that contains the values requested in nstcisMask. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The nstcisMask value specifies which bits in the value pointed to by pnstcisFlags are requested. As a simple example, if /// nstcisMask=NSTCIS_SELECTED, then only the first bit in the value pointed to by pnstcisFlags is valid when this method /// returns. If the first bit in the value pointed to by pnstcisFlags is 1, then the NSTCIS_SELECTED flag is set. If the first /// bit in the value pointed to by pnstcisFlags is 0, then the NSTCIS_SELECTED flag is not set. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getitemstate HRESULT // GetItemState( IShellItem *psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE *pnstcisFlags ); [PreserveSig] new HRESULT GetItemState(IShellItem psi, NSTCITEMSTATE nstcisMask, out NSTCITEMSTATE pnstcisFlags); /// Gets an array of selected Shell items. /// /// Type: IShellItemArray** /// A pointer to an array of selected Shell items. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getselecteditems // HRESULT GetSelectedItems( IShellItemArray **psiaItems ); [PreserveSig] new HRESULT GetSelectedItems(out IShellItemArray psiaItems); /// Gets the state of the checkbox associated with a given Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item for which checkbox state is being retrieved. /// /// /// Type: int* /// A pointer to the state of the checkbox for the Shell item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getitemcustomstate // HRESULT GetItemCustomState( IShellItem *psi, int *piStateNumber ); [PreserveSig] new HRESULT GetItemCustomState(IShellItem psi, out int piStateNumber); /// Sets the state of the checkbox associated with the Shell item. /// /// Type: IShellItem* /// A pointer to the Shell item for which checkbox state is being set. /// /// /// Type: int /// The desired state of the checkbox for the Shell item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-setitemcustomstate // HRESULT SetItemCustomState( IShellItem *psi, int iStateNumber ); [PreserveSig] new HRESULT SetItemCustomState(IShellItem psi, int iStateNumber); /// Ensures that the given item is visible. /// /// Type: IShellItem* /// A pointer to the Shell item for which the visibility is being ensured. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-ensureitemvisible // HRESULT EnsureItemVisible( IShellItem *psi ); [PreserveSig] new HRESULT EnsureItemVisible(IShellItem psi); /// Sets the desktop theme for the current window only. /// /// Type: LPCWSTR /// The name of the desktop theme to which the current window is being set. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-settheme HRESULT // SetTheme( LPCWSTR pszTheme ); [PreserveSig] new HRESULT SetTheme([MarshalAs(UnmanagedType.LPWStr)] string pszTheme); /// Retrieves the next item in the tree according to which method is requested. /// /// Type: IShellItem* /// The Shell item for which the next item is being retrieved. This value can be NULL. /// /// /// Type: NSTCGNI /// The type of the next item. This value can be one of the following flags: /// NSTCGNI_NEXT (0) /// The next sibling of the given item. /// NSTCGNI_NEXTVISIBLE (1) /// /// The next visible item in the tree that has any relationship to the given item. This includes a child (if there is one), the /// next sibling, or even one of the ancestor's siblings. /// /// NSTCGNI_PREV (2) /// The previous sibling item of the given item. /// NSTCGNI_PREVVISIBLE (3) /// The previous visible item that is a sibling item, sibling descendent item or a parent item. /// NSTCGNI_PARENT (4) /// The parent item of the given item. /// NSTCGNI_CHILD (5) /// The first child item of the given item. /// NSTCGNI_FIRSTVISIBLE (6) /// The absolute first visible item in the tree (not relative to the given item). /// NSTCGNI_LASTVISIBLE (7) /// The absolute last visible item in the tree (not relative to the given item). /// /// /// Type: IShellItem** /// The address of a pointer to the IShellItem that fits the criteria for the next item that was requested. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// If there is no next item for the type selected, this function returns E_FAIL with NULL for the returned item, ppsiNext. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getnextitem HRESULT // GetNextItem( IShellItem *psi, NSTCGNI nstcgi, IShellItem **ppsiNext ); [PreserveSig] new HRESULT GetNextItem([In] IShellItem psi, NSTCGNI nstcgi, out IShellItem ppsiNext); /// Retrieves the item that a given point is in, if any. /// /// Type: POINT* /// A pointer to the point to be tested. /// /// /// Type: IShellItem** /// The address of a pointer to the item in which the point exists, or NULL if the point does not exist in an item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// This function returns S_FALSE with a NULL item if the point does not exist in an item. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-hittest HRESULT // HitTest( POINT *ppt, IShellItem **ppsiOut ); [PreserveSig] new HRESULT HitTest(in POINT ppt, out IShellItem ppsiOut); /// Gets the RECT structure that describes the size and position of a given item. /// /// Type: IShellItem* /// A pointer to the item for which the RECT structure is being retrieved. /// /// /// Type: RECT* /// A pointer to the RECT structure that describes the size and position of the item. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-getitemrect HRESULT // GetItemRect( IShellItem *psi, RECT *prect ); [PreserveSig] new HRESULT GetItemRect(IShellItem psi, out RECT prect); /// Collapses all of the items in the given tree. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrol-collapseall HRESULT CollapseAll(); [PreserveSig] new HRESULT CollapseAll(); /// Sets the display styles for the namespace object's treeview controls. /// /// Type: NSTCSTYLE /// One or more of the NSTCSTYLE constants that specify the styles for which the method should set new values. /// /// /// Type: NSTCSTYLE /// /// A bitmap that contains the new values for the styles specified in nstcsMask. If the bit that represents the individual /// NSTCSTYLE value is 0, that style is not used. If the value is 1, the style is applied to the treeview. Styles in positions /// not specified in nstcsMask are left at their current setting regardless of their bit's value in this bitmap. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrol2-setcontrolstyle HRESULT // SetControlStyle( NSTCSTYLE nstcsMask, NSTCSTYLE nstcsStyle ); [PreserveSig] HRESULT SetControlStyle(NSTCSTYLE nstcsMask, NSTCSTYLE nstcsStyle); /// Gets the display styles set for the namespace object's treeview controls. /// /// Type: NSTCSTYLE /// One or more of the NSTCSTYLE constants that specify the values for which the method should retrieve the current settings. /// /// /// Type: NSTCSTYLE* /// /// Pointer to a value that, when this method returns successfully, receives the values requested in nstcsMask. If the bit that /// represents the individual NSTCSTYLE value is 0, that value is not set. If the value is 1, it is the current setting. Bit /// values in positions not specifically requested in nstcsMask do not necessarily reflect the current settings and should not /// be used. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrol2-getcontrolstyle HRESULT // GetControlStyle( NSTCSTYLE nstcsMask, NSTCSTYLE *pnstcsStyle ); [PreserveSig] HRESULT GetControlStyle(NSTCSTYLE nstcsMask, out NSTCSTYLE pnstcsStyle); /// Sets the extended display styles for the namespace object's treeview controls. /// /// Type: NSTCSTYLE2 /// One or more of the NSTCSTYLE2 constants that specify the styles for which the method should set new values. /// /// /// Type: NSTCSTYLE2 /// /// A bitmap that contains the new values for the styles specified in nstcsMask. If the bit that represents the individual /// NSTCSTYLE2 value is 0, that style is not used. If the value is 1, the style is applied to the treeview. Styles in positions /// not specified in nstcsMask are left at their current setting regardless of their bit's value in this bitmap. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrol2-setcontrolstyle2 HRESULT // SetControlStyle2( NSTCSTYLE2 nstcsMask, NSTCSTYLE2 nstcsStyle ); [PreserveSig] HRESULT SetControlStyle2(NSTCSTYLE2 nstcsMask, NSTCSTYLE2 nstcsStyle); /// Gets the extended display styles set for the namespace object's treeview controls. /// /// Type: NSTCSTYLE2 /// One or more of the NSTCSTYLE2 constants that specify the values for which the method should retrieve the current settings. /// /// /// Type: NSTCSTYLE2* /// /// Pointer to a value that, when this method returns successfully, receives the values requested in nstcsMask. If the bit that /// represents the individual NSTCSTYLE2 value is 0, that value is not set. If the value is 1, it is the current setting. Bit /// values in positions not specifically requested in nstcsMask do not necessarily reflect the current settings and should not /// be used. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrol2-getcontrolstyle2 HRESULT // GetControlStyle2( NSTCSTYLE2 nstcsMask, NSTCSTYLE2 *pnstcsStyle ); [PreserveSig] HRESULT GetControlStyle2(NSTCSTYLE2 nstcsMask, out NSTCSTYLE2 pnstcsStyle); } /// /// Exposes handler methods for drag-and-drop. Used by the namespace tree control to notify the client of any drag-and-drop /// operation happening within the control. Provides a way for a client to intercept a drop operation and perform its own action, or /// to return the desired drop effect. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-inamespacetreecontroldrophandler [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("F9C665D6-C2F2-4c19-BF33-8322D7352F51")] public interface INameSpaceTreeControlDropHandler { /// Called on drag enter to set drag effect, as specified. /// /// Type: IShellItem* /// A pointer to an IShellItem interface representing the item underneath the mouse cursor. Optional. /// /// /// Type: IShellItemArray* /// A pointer to an IShellItem array containing the items being dragged. /// /// /// Type: BOOL /// Specifies whether drag started outside target area. /// /// /// Type: DWORD /// The current state of keyboard modifier keys. /// /// /// Type: DWORD* /// On success, contains a pointer to the drag effect value. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// Failing this method blocks the drag operation in the namespace tree control (NSTC). // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontroldrophandler-ondragenter HRESULT // OnDragEnter( IShellItem *psiOver, IShellItemArray *psiaData, BOOL fOutsideSource, DWORD grfKeyState, DWORD *pdwEffect ); [PreserveSig] HRESULT OnDragEnter([In, Optional] IShellItem psiOver, [In] IShellItemArray psiaData, [MarshalAs(UnmanagedType.Bool)] bool fOutsideSource, uint grfKeyState, ref uint pdwEffect); /// Called on drag over to set drag effect, as specified. /// /// Type: IShellItem* /// A pointer to an IShellItem interface representing the item underneath the mouse cursor. Optional. /// /// /// Type: IShellItemArray* /// A pointer to an IShellItem array containing the items being dragged. /// /// /// Type: DWORD /// The current state of keyboard modifier keys. /// /// /// Type: DWORD* /// On success, contains a pointer to the drag effect value. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// Failing this method blocks the drag operation in the namespace tree control (NSTC). // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontroldrophandler-ondragover HRESULT // OnDragOver( IShellItem *psiOver, IShellItemArray *psiaData, DWORD grfKeyState, DWORD *pdwEffect ); [PreserveSig] HRESULT OnDragOver([In, Optional] IShellItem psiOver, [In] IShellItemArray psiaData, uint grfKeyState, ref uint pdwEffect); /// Called when the item is being dragged within the same level (within the same parent folder) in the tree. /// /// Type: IShellItem* /// A pointer to an IShellItem interface representing the item underneath the mouse cursor. Optional. /// /// /// Type: IShellItemArray* /// A pointer to an IShellItem array containing the items being dragged. /// /// /// Type: int /// The index if the item being dragged is between items; otherwise, NSTCDHPOS_ONTOP (-1). /// /// /// Type: int /// The old position. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// Failing this method prevents the item rearrangment. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontroldrophandler-ondragposition // HRESULT OnDragPosition( IShellItem *psiOver, IShellItemArray *psiaData, int iNewPosition, int iOldPosition ); [PreserveSig] HRESULT OnDragPosition([In, Optional] IShellItem psiOver, [In] IShellItemArray psiaData, int iNewPosition, int iOldPosition); /// Called on drop to set drop effect, as specified. /// /// Type: IShellItem* /// A pointer to an IShellItem interface representing the item underneath the mouse cursor. Optional. /// /// /// Type: IShellItemArray* /// A pointer to an IShellItem array representing a data object. /// /// /// Type: int /// Specifies drop position. /// /// /// Type: DWORD /// The current state of keyboard modifier keys. /// /// /// Type: DWORD* /// A pointer to the drop effect value. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// Note To overwrite the default drop behavior, a client should fail this method; success proceeds with the default drop operation. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontroldrophandler-ondrop HRESULT // OnDrop( IShellItem *psiOver, IShellItemArray *psiaData, int iPosition, DWORD grfKeyState, DWORD *pdwEffect ); [PreserveSig] HRESULT OnDrop([In, Optional] IShellItem psiOver, [In] IShellItemArray psiaData, int iPosition, uint grfKeyState, ref uint pdwEffect); /// Called when the item is being dropped within the same level (within the same parent folder) in the tree. /// /// Type: IShellItem* /// A pointer to an IShellItem interface representing the item underneath the mouse cursor. Optional. /// /// /// Type: IShellItemArray* /// A pointer to an IShellItem array representing a data object. /// /// /// Type: int /// The index if the item being dropped is between items; otherwise, NSTCDHPOS_ONTOP (-1). /// /// /// Type: int /// Specifies old position. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// Failing this method prevents the item rearrangment from happening. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontroldrophandler-ondropposition // HRESULT OnDropPosition( IShellItem *psiOver, IShellItemArray *psiaData, int iNewPosition, int iOldPosition ); [PreserveSig] HRESULT OnDropPosition([In, Optional] IShellItem psiOver, [In] IShellItemArray psiaData, int iNewPosition, int iOldPosition); /// Called on drag leave for a specified item. /// /// Type: IShellItem* /// A pointer to an IShellItem interface representing the item underneath the mouse cursor. Optional. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontroldrophandler-ondragleave HRESULT // OnDragLeave( IShellItem *psiOver ); [PreserveSig] HRESULT OnDragLeave([In, Optional] IShellItem psiOver); } /// Exposes methods for handling INameSpaceTreeControl events. /// /// This interface is implemented by a client of namespace control (CLSID_NameSpaceTreeControl) to be advised of namespace control /// events so that the client may process these events and if not, allow the namespace control to process them. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-inamespacetreecontrolevents [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("93D77985-B3D8-4484-8318-672CDDA002CE")] public interface INameSpaceTreeControlEvents { /// Called when the user clicks a button on the mouse. /// /// Type: IShellItem* /// The IShellItem that was clicked. /// /// /// Type: NSTCEHITTEST /// The location on the IShellItem that was clicked. One of the following values: /// NSTCEHT_NOWHERE (0x0001) /// The click missed the IShellItem. /// NSTCEHT_ONITEMICON (0x0002) /// The click was on the icon of the IShellItem. /// NSTCEHT_ONITEMLABEL (0x0004) /// The click was on the label text of the IShellItem. /// NSTCEHT_ONITEMINDENT (0x0008) /// The click was on the indented space on the leftmost side of the IShellItem. /// NSTCEHT_ONITEMBUTTON (0x0010) /// The click was on the expando button of the IShellItem. /// NSTCEHT_ONITEMRIGHT (0x0020) /// The click was on the rightmost side of the text of the IShellItem. /// NSTCEHT_ONITEMSTATEICON (0x0040) /// The click was on the state icon of the IShellItem. /// NSTCEHT_ONITEM (0x0046) /// The click was on the item icon or the item label or the state icon of the IShellItem. /// NSTCEHT_ONITEMTABBUTTON (0x1000) /// The click was on the tab button of the IShellItem. /// /// /// Type: NSTCSTYLE /// Indicates which button was clicked and the kind of click. One of the following values: /// NSTCECT_LBUTTON (0x0001) /// The left button was clicked. /// NSTCECT_MBUTTON (0x0002) /// The middle button was clicked. /// NSTCECT_RBUTTON (0x0003) /// The right button was clicked. /// NSTCECT_BUTTON (0x0003) /// A button was clicked. /// NSTCECT_DBLCLICK (0x0004) /// The click was a double click. If this value is present, it is added to one of the other values. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// If this method fails, the event is processed by both INameSpaceTreeControl and TreeView. If it returns S_OK, then only /// INameSpaceTreeControl will process the event. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onitemclick HRESULT // OnItemClick( IShellItem *psi, NSTCEHITTEST nstceHitTest, NSTCECLICKTYPE nstceClickType ); [PreserveSig] HRESULT OnItemClick([In] IShellItem psi, NSTCEHITTEST nstceHitTest, NSTCECLICKTYPE nstceClickType); /// Not implemented. /// /// Type: IShellItem* /// Not used. /// /// /// Type: HRESULT /// Returns E_NOTIMPL. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onpropertyitemcommit // HRESULT OnPropertyItemCommit( IShellItem *psi ); [PreserveSig] HRESULT OnPropertyItemCommit([In] IShellItem psi); /// Called before the state of an item changes. /// /// Type: IShellItem* /// A pointer to the Shell item for which the state is going to change. /// /// /// Type: NSTCITEMSTATE /// /// One or more values from the NSTCITEMSTATE enumeration that indicate which pieces of information the calling application /// wants to set. /// /// /// /// Type: NSTCITEMSTATE /// One or more values from the NSTCITEMSTATE enumeration that indicate the values that are to be set. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onitemstatechanging // HRESULT OnItemStateChanging( IShellItem *psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisState ); [PreserveSig] HRESULT OnItemStateChanging([In] IShellItem psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisState); /// Not implemented. /// /// Type: IShellItem* /// A pointer to the shell item for which the state has changed. /// /// /// Type: NSTCITEMSTATE /// /// One or more values from the NSTCITEMSTATE enumeration that indicates what pieces of information the caller wants to set. /// /// /// /// Type: NSTCITEMSTATE /// One or more values from the NSTCITEMSTATE enumeration that indicates the values that are to be set. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onitemstatechanged // HRESULT OnItemStateChanged( IShellItem *psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisState ); [PreserveSig] HRESULT OnItemStateChanged([In] IShellItem psi, NSTCITEMSTATE nstcisMask, NSTCITEMSTATE nstcisState); /// Called when the selection changes. /// /// Type: IShellItemArray* /// An array of IShellItem objects that contains the new selection. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onselectionchanged // HRESULT OnSelectionChanged( IShellItemArray *psiaSelection ); [PreserveSig] HRESULT OnSelectionChanged([In] IShellItemArray psiaSelection); /// Called when the user presses a key on the keyboard. /// /// Type: UINT /// The message value. /// /// /// Type: WPARAM /// Specifies the WParam parameters of the message. /// /// /// Type: LPARAM /// Specifies the LParam parameters of the message. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// This method receives its message directly from WndProc. When this returns S_OK, the message was not consumed and the /// namespace tree control is allowed to process the message. Otherwise this message was handled, with no further action required. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onkeyboardinput HRESULT // OnKeyboardInput( UINT uMsg, WPARAM wParam, LPARAM lParam ); [PreserveSig] HRESULT OnKeyboardInput(uint uMsg, IntPtr wParam, IntPtr lParam); /// Called before an IShellItem is expanded. /// /// Type: IShellItem* /// A pointer to the IShellItem that is to be expanded. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onbeforeexpand HRESULT // OnBeforeExpand( IShellItem *psi ); [PreserveSig] HRESULT OnBeforeExpand([In] IShellItem psi); /// Called after an IShellItem is expanded. /// /// Type: IShellItem* /// A pointer to the IShellItem that was expanded. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onafterexpand HRESULT // OnAfterExpand( IShellItem *psi ); [PreserveSig] HRESULT OnAfterExpand([In] IShellItem psi); /// Called before the IShellItem goes into edit mode. /// /// Type: IShellItem* /// Pointer to the IShellItem for which the text is to be edited. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// If this method fails, the transition to edit mode is not canceled. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onbeginlabeledit HRESULT // OnBeginLabelEdit( IShellItem *psi ); [PreserveSig] HRESULT OnBeginLabelEdit([In] IShellItem psi); /// Called after the IShellItem leaves edit mode. /// /// Type: IShellItem* /// A pointer to the IShellItem for which the text was edited. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onendlabeledit HRESULT // OnEndLabelEdit( IShellItem *psi ); [PreserveSig] HRESULT OnEndLabelEdit([In] IShellItem psi); /// Enables you to provide a tooltip. /// /// Type: IShellItem* /// Pointer to the IShellItem that contains the tooltip. /// /// /// Type: LPWSTR /// When this method returns, contains the text of the tooltip. /// /// /// Type: int /// The size of the tooltip in characters. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// If this method returns S_OK, the client provides its own tooltip. Otherwise the INameSpaceTreeControl will extract one. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-ongettooltip HRESULT // OnGetToolTip( IShellItem *psi, LPWSTR pszTip, int cchTip ); [PreserveSig] HRESULT OnGetToolTip([In] IShellItem psi, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszTip, int cchTip); /// Called before an IShellItem and all of its children are deleted. /// /// Type: IShellItem* /// A pointer to the IShellItem that is to be deleted. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// If this method fails, the given IShellItem and its children are still deleted. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onbeforeitemdelete // HRESULT OnBeforeItemDelete( IShellItem *psi ); [PreserveSig] HRESULT OnBeforeItemDelete([In] IShellItem psi); /// Called after an IShellItem has been added. /// /// Type: IShellItem* /// A pointer to the IShellItem that was added. /// /// /// Type: BOOL /// Specifies whether the IShellItem that was added is a root. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onitemadded HRESULT // OnItemAdded( IShellItem *psi, BOOL fIsRoot ); [PreserveSig] HRESULT OnItemAdded([In] IShellItem psi, [MarshalAs(UnmanagedType.Bool)] bool fIsRoot); /// Called after an IShellItem has been deleted. /// /// Type: IShellItem* /// A pointer to the IShellItem that was deleted. /// /// /// Type: BOOL /// Specifies whether the IShellItem that was deleted is a root. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onitemdeleted HRESULT // OnItemDeleted( IShellItem *psi, BOOL fIsRoot ); [PreserveSig] HRESULT OnItemDeleted([In] IShellItem psi, [MarshalAs(UnmanagedType.Bool)] bool fIsRoot); /// Called before a context menu is displayed; allows client to add additional menu entries. /// /// Type: IShellItem* /// A pointer to the IShellItem from which the context menu is generated. This value can be NULL. /// /// /// Type: REFIID /// Reference to the IID of the context menu. /// /// /// Type: void** /// When this methods returns, contains the address of a pointer to the interface specified by riid. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onbeforecontextmenu // HRESULT OnBeforeContextMenu( IShellItem *psi, REFIID riid, void **ppv ); [PreserveSig] HRESULT OnBeforeContextMenu([In, Optional] IShellItem psi, in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 1)] out object ppv); /// Called after a context menu is displayed. /// /// Type: IShellItem* /// /// A pointer to the IShellItem from which the context menu is generated. This value can be NULL only if the /// NSTCS2_SHOWNULLSPACEMENU flag is set. /// /// /// /// Type: IContextMenu* /// A pointer to the context menu. /// /// /// Type: REFIID /// Reference to the IID of the context menu. /// /// /// Type: void** /// When this method returns, contains the address of a pointer to the interface specified in riid. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// This method allows client to completely replace the context menu. This method will allow the client to use the context menu /// returned by ppv and not necessarily the one specified in pcmIn. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onaftercontextmenu // HRESULT OnAfterContextMenu( IShellItem *psi, IContextMenu *pcmIn, REFIID riid, void **ppv ); [PreserveSig] HRESULT OnAfterContextMenu([In, Optional] IShellItem psi, [In] IContextMenu pcmIn, [In] in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 2)] out object ppv); /// Called before the state icon of the given IShellItem is changed. /// /// Type: IShellItem* /// Pointer to the IShellItem in which the state image is changing. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// If this method returns S_OK, the client has processed the event and no further action is required of the namespace control. /// Otherwise the event will need to be processed, in this case the default action is to go to the next image in the list. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolevents-onbeforestateimagechange // HRESULT OnBeforeStateImageChange( IShellItem *psi ); [PreserveSig] HRESULT OnBeforeStateImageChange([In] IShellItem psi); /// Undocumented. /// Undocumented. /// Undocumented. /// Undocumented. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// [PreserveSig] HRESULT OnGetDefaultIconIndex([In] IShellItem psi, out int piDefaultIcon, out int piOpenIcon); } /// Exposes a single method that retrieves the status of a folder's System.IsPinnedToNameSpaceTree filtering support. /// /// /// The namespace tree control checks all the nodes it enumerates to see if they support filtering. This is done by retrieving the /// System.IsPinnedToNameSpaceTree property for the shell folders that support this interface. Nodes that do not support this /// interface do not have filtering support and are shown by default. /// /// Use this interface to retrieve the filtering support status of a shell folder. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-inamespacetreecontrolfoldercapabilities [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("e9701183-e6b3-4ff2-8568-813615fec7be")] public interface INameSpaceTreeControlFolderCapabilities { /// /// Gets a folder's capability to be filtered through the System.IsPinnedToNameSpaceTree property key value and change /// notification registration status. /// /// /// Type: NSTCFOLDERCAPABILITIES /// The capabilities for which this method should retrieve values. Specify one or both of the following: /// NSTCFC_PINNEDITEMFILTERING (0x00000001) /// /// 0x00000001. The System.IsPinnedToNameSpaceTree property exists on this folder and filtering based on that property value is supported. /// /// NSTCFC_DELAY_REGISTER_NOTIFY (0x00000002) /// 0x00000002. Registration for change notifications is delayed until the folder is expanded in the navigation pane. /// /// /// Type: NSTCFOLDERCAPABILITIES* /// /// Pointer to a value that, when this method returns successfully, receives the capabilities requested in nfcMask. Except in /// the case of NSTCFC_NONE, bit values in positions not specifically requested in nfcMask do not necessarily reflect the /// capabilities and should not be used. /// /// NSTCFC_NONE (0x00000000) /// 0x00000000. The System.IsPinnedToNameSpaceTree property does not exist on this folder. Filtering is not supported. /// NSTCFC_PINNEDITEMFILTERING (0x00000001) /// /// 0x00000001. The System.IsPinnedToNameSpaceTree property exists on this folder and filtering based on that property value is supported. /// /// NSTCFC_DELAY_REGISTER_NOTIFY (0x00000002) /// 0x00000002. Registration for change notifications is delayed until the folder is expanded in the navigation pane. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-inamespacetreecontrolfoldercapabilities-getfoldercapabilities // HRESULT GetFolderCapabilities( NSTCFOLDERCAPABILITIES nfcMask, NSTCFOLDERCAPABILITIES *pnfcValue ); [PreserveSig] HRESULT GetFolderCapabilities(NSTCFOLDERCAPABILITIES nfcMask, out NSTCFOLDERCAPABILITIES pnfcValue); } /// Exposes methods that enable the user to draw a custom namespace tree control and its items. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-inamespacetreecontrolcustomdraw [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("2D3BA758-33EE-42d5-BB7B-5F3431D86C78")] internal interface INameSpaceTreeControlCustomDraw { /// Called before the namespace tree control is drawn. /// /// Type: HDC /// A handle to the control's device context. Use this HDC to perform any GDI functions. /// /// /// Type: RECT* /// A pointer to the RECT structure that describes the bounding rectangle of the area being drawn. /// /// /// Type: LRESULT* /// /// When this method returns, contains a pointer to an LRESULT, which contains one or more of the values from the CDRF /// Constants enumeration. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolcustomdraw-prepaint HRESULT // PrePaint( HDC hdc, RECT *prc, LRESULT *plres ); [PreserveSig] HRESULT PrePaint([In] HDC hdc, in RECT prc, out IntPtr plres); /// Called after the namespace tree control is drawn. /// /// Type: HDC /// A handle to the control's device context. Use this HDC to perform any GDI functions. /// /// /// Type: RECT* /// A pointer to the RECT structure that describes the bounding rectangle of the area being drawn. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolcustomdraw-postpaint HRESULT // PostPaint( HDC hdc, RECT *prc ); [PreserveSig] HRESULT PostPaint([In] HDC hdc, in RECT prc); /// Called before an item in the namespace tree control is drawn. /// /// Type: HDC /// A handle to the control's device context. Use this HDC to perform any GDI functions. /// /// /// Type: RECT* /// A pointer to the RECT structure that describes the bounding rectangle of the area being drawn. /// /// /// Type: NSTCCUSTOMDRAW* /// A pointer to the NSTCCUSTOMDRAW structure that determines the details of the drawing. /// /// /// Type: COLORREF* /// /// On entry, a pointer to a COLORREF structure that declares the default color of the text. When this method returns, contains /// a pointer to a COLORREF structure that declares the color that should be used in its place, if any. This allows the /// client to provide their own color if they do not want to use the default. /// /// /// /// Type: COLORREF* /// /// On entry, a pointer to a COLORREF structure that declares the default color of the background. When this method returns, /// contains a pointer to a COLORREF structure that declares the color that should be used in its place, if any. This /// allows the client to provide their own color if they do not want to use the default. /// /// /// /// Type: LRESULT* /// /// When this method returns, contains a pointer to an LRESULT, which points to one or more of the values from the CDRF /// Constants enumeration. /// /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolcustomdraw-itemprepaint HRESULT // ItemPrePaint( HDC hdc, RECT *prc, NSTCCUSTOMDRAW *pnstccdItem, COLORREF *pclrText, COLORREF *pclrTextBk, LRESULT *plres ); [PreserveSig] HRESULT ItemPrePaint([In] HDC hdc, in RECT prc, in NSTCCUSTOMDRAW pnstccdItem, ref COLORREF pclrText, ref COLORREF pclrTextBk, out IntPtr plres); /// Called after an item in the namespace tree control is drawn. /// /// Type: HDC /// A handle to the control's device context. Use this HDC to perform any GDI functions. /// /// /// Type: RECT* /// A pointer to the RECT structure that describes the bounding rectangle of the area being drawn. /// /// /// Type: NSTCCUSTOMDRAW* /// A pointer to the NSTCCUSTOMDRAW struct that determines the details of the drawing. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-inamespacetreecontrolcustomdraw-itempostpaint HRESULT // ItemPostPaint( HDC hdc, RECT *prc, NSTCCUSTOMDRAW *pnstccdItem ); [PreserveSig] HRESULT ItemPostPaint([In] HDC hdc, in RECT prc, in NSTCCUSTOMDRAW pnstccdItem); } /// Custom draw structure used by INameSpaceTreeControlCustomDraw methods. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/ns-shobjidl-nstccustomdraw typedef struct NSTCCUSTOMDRAW { IShellItem // *psi; UINT uItemState; NSTCITEMSTATE nstcis; LPCWSTR pszText; int iImage; HIMAGELIST himl; int iLevel; int iIndent; } NSTCCUSTOMDRAW; [PInvokeData("shobjidl.h", MSDNShortId = "95747075-4882-4c29-8653-941ac04db54b")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct NSTCCUSTOMDRAW { /// /// Type: IShellItem* /// A pointer to a Shell item. /// public IShellItem psi; /// /// Type: UINT /// The current item state. See NMCUSTOMDRAW for more detail. /// public uint uItemState; /// /// Type: NSTCITEMSTATE /// The state of a tree item. See NSTCITEMSTATE. /// public NSTCITEMSTATE nstcis; /// /// Type: LPCWSTR /// A pointer to a null-terminated Unicode string that contains the item text, if the structure specifies item attributes. /// [MarshalAs(UnmanagedType.LPWStr)] public string pszText; /// /// Type: int /// The index in the tree-view control's image list. /// public int iImage; /// /// Type: HIMAGELIST /// A handle to an image list. /// public HIMAGELIST himl; /// /// Type: int /// The zero-based level of the item being drawn. /// public int iLevel; /// /// Type: int /// A tree-level indent. /// public int iIndent; } /// CLSID_NameSpaceTreeControl [ComImport, Guid("AE054212-3535-4430-83ED-D501AA6680E6"), ClassInterface(ClassInterfaceType.None)] public class NameSpaceTreeControl { } } }