Click here to Skip to main content
15,881,172 members
Articles / Programming Languages / C#

TreeListView

Rate me:
Please Sign up or sign in to vote.
4.79/5 (147 votes)
31 Aug 2003Ms-PL5 min read 1.5M   38.4K   436  
A custom control that ties a ListView and a TreeView together
using System;
using System.Runtime.InteropServices;

namespace System.Runtime.InteropServices.APIs
{
	public class APIsMenu
	{
		[DllImport("user32.dll")]
		public static extern APIsEnums.MenuItemFlags GetMenuState(
			IntPtr hMenu, int itemID, APIsEnums.MenuItemFlags uFlag);
		[DllImport("user32.dll")]
		public static extern bool GetMenuString(
			IntPtr hMenu, int itemID, System.Text.StringBuilder lpString, int maxlen, APIsEnums.MenuItemFlags uFlag);
		[DllImport("user32.dll")]
		public static extern int GetMenuItemInfo(
			IntPtr hMenu, int itemindex, bool fByPosition, ref APIsStructs.MENUITMEINFO infos);
		[DllImport("user32.dll")]
		public static extern int GetMenuItemID(
			IntPtr hMenu, int index);
		[DllImport("user32.dll")]
		public static extern bool InsertMenuItem(
			IntPtr hMenu, int itemindex, bool fByPosition, ref APIsStructs.MENUITMEINFO infos);
		[DllImport("user32.dll")]
		public static extern int GetMenuItemCount(IntPtr hMenu);
		[DllImport("user32.dll")]
		public static extern IntPtr CreatePopupMenu();
		[DllImport("user32.dll")]
		public static extern bool DestroyMenu(IntPtr hMenu);
		[DllImport("user32.dll")]
		public static extern bool DeleteMenu(
			IntPtr hMenu,
			int index,
			APIsEnums.MenuItemFlags uFlag);
		[DllImport("user32.dll", SetLastError=true)]
		public static extern int TrackPopupMenu(
			IntPtr hmenu,
			APIsEnums.TrackPopupMenuFlags fuFlags,
			int x,
			int y,
			int res,
			IntPtr hwnd,
			IntPtr rect);
	}
}

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 The Microsoft Public License (Ms-PL)


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

Comments and Discussions