OnMenuKey() 개인적인 메소드

private OnMenuKey ( ) : bool
리턴 bool
예제 #1
0
        internal static bool ProcessMenuKey(ref Message m)
        {
            // If we have a currently active menu, deactivate it
            if (Application.KeyboardCapture != null)
            {
                if (Application.KeyboardCapture.OnMenuKey())
                {
                    return(true);
                }
            }

            // Get the parent form of this message
            Form f = (Form)Control.FromHandle(m.HWnd).TopLevelControl;

            // If there isn't a Form with this, there isn't much we can do
            if (f == null)
            {
                return(false);
            }

            // Check the MainMenuStrip property first
            if (f.MainMenuStrip != null)
            {
                if (f.MainMenuStrip.OnMenuKey())
                {
                    return(true);
                }
            }

            // Look for any MenuStrip in the form
            lock (toolstrips)
                foreach (WeakReference wr in toolstrips)
                {
                    ToolStrip ts = (ToolStrip)wr.Target;

                    if (ts == null)
                    {
                        continue;
                    }

                    if (ts.TopLevelControl == f)
                    {
                        if (ts.OnMenuKey())
                        {
                            return(true);
                        }
                    }
                }

            return(false);
        }