How to detect mouse over on title bar or mouse out from title bar in c# winform apps
<p>i want to detect mouse over on title bar or mouse out from title bar in my c# winform apps.
i got a code which works but the problem is when i place the mouse on any area of win form then mouse leave occur and when i put mouse on title bar then right event call. here is the code</p>

<pre><code>using System.Runtime.InteropServices;
public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
            {
                TrackNcMouseLeave(this);
                //ShowClientArea();
                label1.Text = "mouse move on title bar";
            }
            else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
            {
                //HideClientAreaIfPointerIsOut();
                label1.Text = "mouse leave from title bar";
            }

            base.WndProc(ref m);
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            //HideClientAreaIfPointerIsOut();
        }

        private int previouseHeight;

        private void ShowClientArea()
        {
            if (this.ClientSize.Height == 0)
                this.ClientSize = new Size(this.ClientSize.Width, previouseHeight);
        }

        private void HideClientAreaIfPointerIsOut()
        {
            if (this.Bounds.Contains(Cursor.Position))
                return;
            previouseHeight = this.ClientSize.Height;
            this.ClientSize = new Size(this.ClientSize.Width, 0);
        }

        public static void TrackNcMouseLeave(Control control)
        {
            TRACKMOUSEEVENT tme = new TRACKMOUSEEVENT();
            tme.cbSize = (uint)Marshal.SizeOf(tme);
            tme.dwFlags = 2 | 0x10; // TME_LEAVE | TME_NONCLIENT
            tme.hwndTrack = control.Handle;
            TrackMouseEvent(tme);
        }

        [DllImport("user32")]
        public static extern bool TrackMouseEvent([In, Out] TRACKMOUSEEVENT lpEventTrack);

        [StructLayout(LayoutKind.Sequential)]
        public class TRACKMOUSEEVENT
        {
            public uint cbSize;
            public uint dwFlags;
            public IntPtr hwndTrack;
            public uint dwHoverTime;
        }
    }
</code></pre>

<p>so some one please guide me what i need to change as a result when i will place mouse on body then i should not be notified. thanks</p>
