.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use the Menu class?

3 REPLIES 3
Reply
Message 1 of 4
tangferry
311 Views, 3 Replies

How to use the Menu class?

Autodesk.AutoCAD.Windows namespace has the Menu class.But how to use it?
3 REPLIES 3
Message 2 of 4
Anonymous
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?
Message 3 of 4
tangferry
in reply to: tangferry

Thanks for your answer.But can I use it to create my own popup menus in the menu bar?
Message 4 of 4
Anonymous
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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost