|
//
// TreeView with more useful context-menu handling
//
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MultiPlug.MultiApp
{
public class RepairedTreeView : TreeView
{
public event TreeViewEventHandler MouseContextMenu;
public Point ContextPoint
{ get { return contextPoint; } }
private Point contextPoint;
private const int WM_CONTEXTMENU = 0x007B;
protected override void WndProc( ref Message m )
{
if( m.Msg == WM_CONTEXTMENU )
{
TreeNode ctxNode = null;
int lparam = (int) m.LParam;
if( lparam == -1 ) // keyboard SHIFT+F10
{
ctxNode = this.SelectedNode;
if( ctxNode != null )
contextPoint = new Point( ctxNode.Bounds.X + 16, ctxNode.Bounds.Y + 8 );
}
else
{
int x = (short) lparam;
int y = lparam >> 16;
contextPoint = this.PointToClient( new Point( x, y ) );
ctxNode = this.GetNodeAt( contextPoint );
}
if( ctxNode != null )
{
TreeViewEventArgs aa = new TreeViewEventArgs( ctxNode, TreeViewAction.Unknown );
if( MouseContextMenu != null )
MouseContextMenu( this, aa );
return;
}
}
base.WndProc( ref m );
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.