<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Controls &#8211; Aykut Çevik</title>
	<atom:link href="https://aykutcevik.com/blog/tag/controls/feed/" rel="self" type="application/rss+xml" />
	<link>https://aykutcevik.com/blog</link>
	<description>coding &#38; projects</description>
	<lastBuildDate>Thu, 16 Nov 2017 13:08:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>Aero TreeView like Windows Explorer &#8211; C#</title>
		<link>https://aykutcevik.com/blog/aero-treeview-like-windows-explorer-c/</link>
					<comments>https://aykutcevik.com/blog/aero-treeview-like-windows-explorer-c/#respond</comments>
		
		<dc:creator><![CDATA[Aykut Çevik]]></dc:creator>
		<pubDate>Wed, 08 Dec 2010 19:07:19 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programmieren]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Aero]]></category>
		<category><![CDATA[Controls]]></category>
		<category><![CDATA[Flickerfree]]></category>
		<category><![CDATA[TreeView]]></category>
		<guid isPermaLink="false">http://aykutcevik.com/?p=201</guid>

					<description><![CDATA[Mit diesem Snippet, eine Modifikation der System.Windows.Forms.TreeView, könnt ihr eure TreeView wie die im Windows Explorer darstellen. Das &#8220;Control&#8221; ist flackerfrei und unterstützt auch ältere Systeme vor Vista und Windows 7. Der &#8220;Windows Explorer&#8221;-Stil ist jedoch erst ab Vista verfügbar. Einige Funktionen: Die &#8220;ShowPlusMinus&#8221;-Eigenschaft wird wie im Explorer ein- und ausgeblendet, sobald das Control den [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Mit diesem Snippet, eine Modifikation der <strong>System.Windows.Forms.TreeView</strong>, könnt ihr eure TreeView wie die im Windows Explorer darstellen.</p>
<p>Das &#8220;Control&#8221; ist flackerfrei und unterstützt auch ältere Systeme vor Vista und Windows 7. Der &#8220;Windows Explorer&#8221;-Stil ist jedoch erst ab Vista verfügbar.</p>
<p><span id="more-201"></span>Einige Funktionen:</p>
<ul>
<li>Die <strong>&#8220;ShowPlusMinus&#8221;-Eigenschaft wird wie im Explorer ein- und ausgeblendet</strong>, sobald das Control den Fokus erhält bzw. verliert.</li>
<li>Die horizontale Scrollbar entfällt, die <strong>TreeView scrollt automatisch</strong>.</li>
<li>Die Markierung einer &#8220;Node&#8221; ist wie im Windows Explorer <strong>grafisch hochwertiger</strong>.</li>
<li>Die TreeView ist <strong>flackerfrei</strong>.</li>
</ul>
<p>Hier der Code der<strong> TreeViewAero.cs</strong>:</p>
<pre>using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;

namespace System.Windows.Forms
{
    /// &lt;summary&gt;
    /// A stylish treeview like the one from Windows Explorer 
    /// &lt;/summary&gt;
    [DesignerCategory("Code")]
    [ToolboxBitmap(typeof(TreeView))]
    public class TreeViewAero : TreeView
    {
        public TreeViewAero()
        {
            // sets double buffering for flickerfree treeview
            base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);

            // like the one in Windows Explorer
            base.ShowLines = false;
            base.HideSelection = false;
        }

        /// &lt;summary&gt;
        /// OnPaint-Method, modified for UserPaint-Flag at Style
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;base PaintEventArgs&lt;/param&gt;
        protected override void OnPaint(PaintEventArgs e)
        {
            if (GetStyle(ControlStyles.UserPaint))
            {
                // create new message
                Message m = new Message();

                // content handle
                m.HWnd = this.Handle;

                // message itself
                m.Msg = 0x0318; // WM_PRINTCLIENT message

                // params
                m.WParam = e.Graphics.GetHdc();
                m.LParam = (IntPtr)4; // PRF_CLIENT message

                // send this message
                DefWndProc(ref m);

                // release hdc
                e.Graphics.ReleaseHdc(m.WParam);
            }

            // do the basics
            base.OnPaint(e);
        }

        /// &lt;summary&gt;
        /// OnHandleCreated-Method
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;base EventArgs&lt;/param&gt;
        protected override void OnHandleCreated(EventArgs e)
        {
            // do the basics
            base.OnHandleCreated(e);

            // set the theme of this treeview from "explorer" (application name)
            NativeMethods.SetWindowTheme(base.Handle, "explorer", null);

            if (Environment.OSVersion.Version.Major &gt; 5) // greater than xp
            {
                // send some messages for the stylish effects
                IntPtr lParam = (IntPtr)(NativeMethods.SendMessage(base.Handle, 0x112d, IntPtr.Zero, IntPtr.Zero).ToInt32() | 0x60);
                NativeMethods.SendMessage(base.Handle, 0x112c, IntPtr.Zero, lParam);
            }
        }

        /// &lt;summary&gt;
        /// CreateParams-Property
        /// &lt;/summary&gt;
        protected override CreateParams CreateParams
        {
            get
            {
                // get base params
                CreateParams createParams = base.CreateParams;

                if (Environment.OSVersion.Version.Major &gt; 5) // greater than xp
                {
                    // a bitwise logical OR operation
                    createParams.Style |= 0x8000;
                }

                // return the modified value
                return createParams;
            }
        }
    }

    public abstract class NativeMethods
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
        public static extern int SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList);
    }
}
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://aykutcevik.com/blog/aero-treeview-like-windows-explorer-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>