Click here to Skip to main content
15,892,537 members
Articles / Programming Languages / C#

LiveCode.NET

Rate me:
Please Sign up or sign in to vote.
4.86/5 (55 votes)
6 May 2002Public Domain3 min read 231.7K   2.5K   170  
Compile C# code on-the-fly. Usage in a plug-in / plug-out component model.
//
//  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.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Web Developer
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions