2010-12-08 87 views
3

在uTorrent 2.2中,當選擇樹視圖節點時,該節點具有類似的按鈕外觀。它使.NET的treeview控件看起來對我來說太不合適了。現在我知道utorrent是用C++編寫的,但是有誰知道他們是如何做到這一點的,或者是否有人知道那裏的圖書館足夠了?TreeView控件類似於utorrent的控件

alt text

回答

4

它與Win7的 「資源管理器」 視覺應用的樣式一個標準的Windows TreeView控件。通過更改控件的主題,您可以輕鬆地在自己的程序中獲得一個。爲您的項目添加一個新類並粘貼下面顯示的代碼。編譯。將新的控件從工具箱的頂部拖放到表單上。

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的直接可能。