How to use the Menu class?

How to use the Menu class?

Anonymous
Not applicable
647 Views
3 Replies
Message 1 of 4

How to use the Menu class?

Anonymous
Not applicable
Autodesk.AutoCAD.Windows namespace has the Menu class.But how to use it?
0 Likes
648 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
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?
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks for your answer.But can I use it to create my own popup menus in the menu bar?
0 Likes
Message 4 of 4

Anonymous
Not applicable
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?
0 Likes