/// <summary> /// Modify a WinForms TreeView control to use the new Explorer style theme /// </summary> /// <param name="treeView">The tree view control to modify</param> public static void ApplyTreeViewThemeStyles(TreeView treeView) { ArgumentNullException.ThrowIfNull(treeView); treeView.HotTracking = true; treeView.ShowLines = false; IntPtr hwnd = treeView.Handle; ComCtl32.TVS_EX exstyle = (ComCtl32.TVS_EX)User32.SendMessageW(hwnd, (User32.WM)ComCtl32.TVM.GETEXTENDEDSTYLE); exstyle |= ComCtl32.TVS_EX.DOUBLEBUFFER | ComCtl32.TVS_EX.FADEINOUTEXPANDOS; User32.SendMessageW(hwnd, (User32.WM)ComCtl32.TVM.SETEXTENDEDSTYLE, 0, (nint)exstyle); }
/// <summary> /// Modify a WinForms TreeView control to use the new Explorer style theme /// </summary> /// <param name="treeView">The tree view control to modify</param> public static void ApplyTreeViewThemeStyles(TreeView treeView) { if (treeView == null) { throw new ArgumentNullException(nameof(treeView)); } treeView.HotTracking = true; treeView.ShowLines = false; IntPtr hwnd = treeView.Handle; ComCtl32.TVS_EX exstyle = TreeView_GetExtendedStyle(hwnd); exstyle |= ComCtl32.TVS_EX.DOUBLEBUFFER | ComCtl32.TVS_EX.FADEINOUTEXPANDOS; TreeView_SetExtendedStyle(hwnd, exstyle, 0); }
/// <summary> /// Modify a WinForms TreeView control to use the new Explorer style theme /// </summary> /// <param name="treeView">The tree view control to modify</param> public static void ApplyTreeViewThemeStyles(TreeView treeView) { if (treeView is null) { throw new ArgumentNullException(nameof(treeView)); } treeView.HotTracking = true; treeView.ShowLines = false; IntPtr hwnd = treeView.Handle; ComCtl32.TVS_EX exstyle = (ComCtl32.TVS_EX)User32.SendMessageW(hwnd, (User32.WM)ComCtl32.TVM.GETEXTENDEDSTYLE); exstyle |= ComCtl32.TVS_EX.DOUBLEBUFFER | ComCtl32.TVS_EX.FADEINOUTEXPANDOS; User32.SendMessageW(hwnd, (User32.WM)ComCtl32.TVM.SETEXTENDEDSTYLE, IntPtr.Zero, (IntPtr)exstyle); }
private static void TreeView_SetExtendedStyle(IntPtr handle, ComCtl32.TVS_EX extendedStyle, int mask) { User32.SendMessageW(handle, (User32.WindowMessage)NativeMethods.TVM_SETEXTENDEDSTYLE, (IntPtr)mask, (IntPtr)extendedStyle); }