Frans ran into some trouble disabling parent menu items.  Turns out they dont disable the evaluation of child shortcuts.  This was an oversight on our part.  That said, most applications remove flyouts that are not in-use so as to not taunt users with menus they can't click on.  =)

 

Here's a quick workaround.  Add this to your project and replace your ToolStripMenuItems with this type.

 

Hope this helps! 

 

---

 

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsApplication51 {

    /// <summary>

    /// Workaround for disabled flyout menus still evaluating shortcuts

    /// </summary>

    public class FullyEnabledMenuItem : ToolStripMenuItem {

        protected override bool ProcessCmdKey(ref Message m, Keys keyData) {

 

            if (!IsEveryoneEnabled()) {

                // store off the current state of enabled-ness

                bool isEnabled = Enabled;

                this.Enabled = false;

 

                // process the shortcut

                bool handled = base.ProcessCmdKey(ref m, keyData);

 

                // restore the state of enabledness

                this.Enabled = isEnabled;

 

                // return the result of processcmdkey

                return handled;

            }

            else {

                // everyone was enabled

                return base.ProcessCmdKey(ref m, keyData);

            }

        }

 

        private bool IsEveryoneEnabled() {

            if (!this.Enabled) {

                return false;

            }

 

            // walk up the owning item chain until the top

            ToolStripItem ownerItem = this.OwnerItem;

            while (ownerItem != null) {

                if (!ownerItem.Enabled) {

                    return false;

                }

                ownerItem = ownerItem.OwnerItem;

            }

            return true;

        }

    }

}