.NET

Reply
Active Contributor
tangferry
Posts: 43
Registered: ‎04-21-2005
Message 1 of 4 (179 Views)

How to use the Menu class?

179 Views, 3 Replies
07-06-2005 06:45 PM
Autodesk.AutoCAD.Windows namespace has the Menu class.But how to use it?
*Albert Szilvasy
Message 2 of 4 (179 Views)

Re: How to use the Menu class?

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.Editor.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?
Active Contributor
tangferry
Posts: 43
Registered: ‎04-21-2005
Message 3 of 4 (179 Views)

Re: How to use the Menu class?

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
Message 4 of 4 (179 Views)

Re: How to use the Menu class?

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?
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.