类似于utorrent的TreeView控件

3
在uTorrent 2.2中,当选择一个树形视图节点时,该节点具有类似按钮的外观。这使得.NET树形视图控件对我来说显得如此不足。现在我知道utorrent是用C++编写的,但是否有人知道他们是如何做到的,或者是否有适合的库可用?
1个回答

4

这是一个标准的Windows TreeView控件,应用了Win7“资源管理器”视觉样式。您可以通过更改控件的主题轻松地在自己的程序中获取一个。将下面显示的代码粘贴到项目中添加一个新类。编译。从工具箱的顶部将新控件拖放到您的表单上。

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

class MyTreeView : TreeView {
    protected override void OnHandleCreated(EventArgs e) {
        if (Environment.OSVersion.Version.Major >= 6) {
            SetWindowTheme(this.Handle, "Explorer", null);
        }
        base.OnHandleCreated(e);
    }
    [DllImportAttribute("uxtheme.dll", CharSet = CharSet.Auto)]
    private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);
}

如果不使用WindowsFormHost类,WPF无法直接实现这一点。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接