.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to use the Menu class?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
143 Views, 3 Replies
07-06-2005 06:45 PM
Autodesk.AutoCAD.Windows namespace has the Menu class.But how to use it?
*Albert Szilvasy
Re: How to use the Menu class?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-07-2005 10:20 AM in reply to:
tangferry
Here's an example:
public class TestObjectContextMenu
{
public class MyContextMenu : ContextMenuExtension
{
private MenuItem m_main = new MenuItem("MAIN MENU");
private MenuItem m_sub0 = new MenuItem("SUBMENU 0");
private MenuItem m_sub1 = new MenuItem("SUBMENU 1");
private MenuItem m_sub2 = new MenuItem("SUBMENU 2");
static public bool m_bShowExtraMenus = true;
public MyContextMenu()
{
this.Title = "Test";
this.MenuItems.Add(m_main);
m_main.MenuItems.Add(m_sub0);
m_main.MenuItems.Add(m_sub1);
this.Popup += new EventHandler(OnUpdateMenu);
m_sub0.Click += new EventHandler(OnClick);
m_sub1.Click += new EventHandler(OnClick);
m_sub2.Click += new EventHandler(OnClick);
}
void OnClick(object sender, EventArgs e)
{
}
void OnUpdateMenu(object sender, EventArgs e)
{
ContextMenuExtension cme = (ContextMenuExtension) sender;
if (MyContextMenu.m_bShowExtraMenus)
{
if (!m_main.MenuItems.Contains(m_sub2))
{
m_main.MenuItems.Add(m_sub2);
}
}
else
{
if (m_main.MenuItems.Contains(m_sub2))
{
m_main.MenuItems.Remove(m_sub2);
}
}
// toggle
MyContextMenu.m_bShowExtraMenus =
!MyContextMenu.m_bShowExtraMenus;
}
};
[CommandMethod("MENUTEST")]
public static void DoIt()
{
Application.DocumentManager.MdiActiveDocument.Edit or.WriteMessage("Registering
Object Context menu for circle...\n");
MyContextMenu cme = new MyContextMenu();
Application.AddObjectContextMenuExtension(RXObject .GetClass(typeof
(Circle)), cme);
}
}
wrote in message news:4894632@discussion.autodesk.com...
Autodesk.AutoCAD.Windows namespace has the Menu class.But how to use it?
public class TestObjectContextMenu
{
public class MyContextMenu : ContextMenuExtension
{
private MenuItem m_main = new MenuItem("MAIN MENU");
private MenuItem m_sub0 = new MenuItem("SUBMENU 0");
private MenuItem m_sub1 = new MenuItem("SUBMENU 1");
private MenuItem m_sub2 = new MenuItem("SUBMENU 2");
static public bool m_bShowExtraMenus = true;
public MyContextMenu()
{
this.Title = "Test";
this.MenuItems.Add(m_main);
m_main.MenuItems.Add(m_sub0);
m_main.MenuItems.Add(m_sub1);
this.Popup += new EventHandler(OnUpdateMenu);
m_sub0.Click += new EventHandler(OnClick);
m_sub1.Click += new EventHandler(OnClick);
m_sub2.Click += new EventHandler(OnClick);
}
void OnClick(object sender, EventArgs e)
{
}
void OnUpdateMenu(object sender, EventArgs e)
{
ContextMenuExtension cme = (ContextMenuExtension) sender;
if (MyContextMenu.m_bShowExtraMenus)
{
if (!m_main.MenuItems.Contains(m_sub2))
{
m_main.MenuItems.Add(m_sub2);
}
}
else
{
if (m_main.MenuItems.Contains(m_sub2))
{
m_main.MenuItems.Remove(m_sub2);
}
}
// toggle
MyContextMenu.m_bShowExtraMenus =
!MyContextMenu.m_bShowExtraMenus;
}
};
[CommandMethod("MENUTEST")]
public static void DoIt()
{
Application.DocumentManager.MdiActiveDocument.Edit
Object Context menu for circle...\n");
MyContextMenu cme = new MyContextMenu();
Application.AddObjectContextMenuExtension(RXObject
(Circle)), cme);
}
}
Autodesk.AutoCAD.Windows namespace has the Menu class.But how to use it?
Re: How to use the Menu class?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-07-2005 05:29 PM in reply to:
tangferry
Thanks for your answer.But can I use it to create my own popup menus in the menu bar?
*Albert Szilvasy
Re: How to use the Menu class?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-07-2005 07:32 PM in reply to:
tangferry
No. You should use the COM API to do that (MenuBar, MenuGroup and co) They
work perfectly well from any .NET language.
Albert
wrote in message news:4895840@discussion.autodesk.com...
Thanks for your answer.But can I use it to create my own popup menus in the
menu bar?
work perfectly well from any .NET language.
Albert
Thanks for your answer.But can I use it to create my own popup menus in the
menu bar?
