Skip to content

Commit

Permalink
Fix for TreeView
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
MaeBee committed Sep 15, 2017
1 parent 6495074 commit 855daf9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ESOResearchNotifier/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions ESOResearchNotifier/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,31 @@ public class TreeMetaNode: TreeNode
{
public object MetaValue { get; set; }
}

public partial class FixedTreeView : TreeView
{
private const int WM_LBUTTONDBLCLK = 0x0203;
private const int WM_RBUTTONDOWN = 0x0204;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONDBLCLK)
{
// disable double-click on checkbox to fix Microsoft Vista bug
TreeViewHitTestInfo tvhti = HitTest(new System.Drawing.Point((int)m.LParam));
if (tvhti != null && tvhti.Location == TreeViewHitTestLocations.StateImage)
{
m.Result = IntPtr.Zero;
return;
}
}
else if (m.Msg == WM_RBUTTONDOWN)
{
// set focus to node on right-click - another Microsoft bug?
TreeViewHitTestInfo tvhti = HitTest(new System.Drawing.Point((int)m.LParam));
if (tvhti != null)
this.SelectedNode = tvhti.Node;
}
base.WndProc(ref m);
}
}
}

1 comment on commit 855daf9

@MaeBee
Copy link
Owner Author

@MaeBee MaeBee commented on 855daf9 Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution found on the MSDN forums, suggested by user swiss matt.

Please sign in to comment.