Tabbed MDI Context Menu Customization

Docking/MDI for Windows Forms Forum

Posted 13 years ago by William Lucking - Owner, Ephron Inc
Avatar
Is there an event that fires when someone right clicks the MDI document tabs, prior to the standard context menu displaying so as to allow someone to add additional menu items to the standard menu?

Comments (7)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes the DockManager.WindowContextMenu event fires. In that you can cancel the menu and provide your own menu instead. There are a number of methods on each TabbedMdiWindow class, such as IsMenuItemChecked, IsMenuItemEnabled, and IsMenuItemVisible. You can use those to determine which menu items should be on the menu that is being displayed. Unfortunately there is no way to add new items to the default menu. You have to replace it with your own menu instead.


Actipro Software Support

Posted 13 years ago by William Lucking - Owner, Ephron Inc
Avatar
That's great and everything, but I would like to make some suggestions.

I would like to keep your standard functionality related to vertical and horizontal tab groups without having to code a new context menu and menu items to manage that functionality. So, if you can include the actual context menu object as a property in ActiproSoftware.UIStudio.Dock.TabbedMdiWindowContextMenuEventArgs that would be great.

Also, there would be no desire on my part to customize the menu if it had a simple menu item of "Close All But This", similiar to what is offered in VS 2005 and what I've seen in other applications that I surprisingly often use.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok, the next maintenance release will have a Close All But This option built in as well as the default ContextMenu being passed in the event args.


Actipro Software Support

Posted 8 years ago by Lorenzo - Italy
Avatar
Hi,

I tried to customize the menù keeping the old items and adding mine, but it doesn't work. This is my code:

void dockManager1_WindowContextMenu(object sender, TabbedMdiWindowContextMenuEventArgs e)
{
   ActiproSoftware.WinUICore.OwnerDrawContextMenu myMenu = new ActiproSoftware.WinUICore.OwnerDrawContextMenu();
   foreach(MenuItem mi in e.DefaultContextMenu.MenuItems)
   {
      myMenu.MenuItems.Add(mi.CloneMenu());
   }
   myMenu.MenuItems.Add("My Menu New Item");
   e.DefaultContextMenu = myMenu;
}
Can you please help me fix that problem?

Thanks,
Lorenzo
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Lorenzo,

Why not just add your menu item to the e.DefaultContextMenu one (I believe that works)?

Or if you want to keep it like it is now, remove the menu items from e.DefaultContextMenu and use them directly in myMenu.


Actipro Software Support

Posted 8 years ago by Lorenzo - Italy
Avatar
Hi,

thanks for your reply.
If I add one new item, the new item added has a totally different rendering from the others.

This is my code:

void dockManager1_WindowContextMenu(object sender, TabbedMdiWindowContextMenuEventArgs e)
{
   e.DefaultContextMenu.MenuItems.Add("A sample item");
}
Thanks for your reply.
Lorenzo
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Lorenzo,

You have to add an OwnerDrawMenuItem instance. The MenuItems.Add method you called just adds regular MenuItem instances, which won't render the same.


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.