CodeWalker/CodeWalker.WinForms/TreeViewFix.cs

41 lines
1000 B
C#
Raw Normal View History

2018-03-14 10:28:58 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CodeWalker.WinForms
{
public partial class TreeViewFix : TreeView
{
public TreeViewFix()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x203) // double click
{
var localPos = PointToClient(Cursor.Position);
var hitTestInfo = HitTest(localPos);
if (hitTestInfo.Location == TreeViewHitTestLocations.StateImage)
m.Result = IntPtr.Zero;
else
base.WndProc(ref m);
}
else base.WndProc(ref m);
}
}
}