protected override bool ProcessCmdKey(ref Message m, Keys keyData) { if ((!ToolStripManager.ModalMenuFilter.InMenuMode || (keyData != Keys.Space)) || (!this.Focused && base.ContainsFocus)) { return(base.ProcessCmdKey(ref m, keyData)); } base.NotifySelectionChange(null); ToolStripManager.ModalMenuFilter.ExitMenuMode(); System.Windows.Forms.UnsafeNativeMethods.PostMessage(WindowsFormsUtils.GetRootHWnd(this), 0x112, 0xf100, 0x20); return(true); }
protected override void WndProc(ref Message m) { if ((m.Msg == NativeMethods.WM_NCHITTEST) && SizingGrip) { // if we're within the grip bounds tell windows // that we're the bottom right of the window. Rectangle sizeGripBounds = SizeGripBounds; int x = NativeMethods.Util.LOWORD(m.LParam); int y = NativeMethods.Util.HIWORD(m.LParam); if (sizeGripBounds.Contains(PointToClient(new Point(x, y)))) { HandleRef rootHwnd = WindowsFormsUtils.GetRootHWnd(this); // if the main window isnt maximized - we should paint a resize grip. // double check that we're at the bottom right hand corner of the window. if (rootHwnd.Handle != IntPtr.Zero && !UnsafeNativeMethods.IsZoomed(rootHwnd)) { // get the client area of the topmost window. If we're next to the edge then // the sizing grip is valid. NativeMethods.RECT rootHwndClientArea = new NativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(rootHwnd, ref rootHwndClientArea); // map the size grip FROM statusStrip coords TO the toplevel window coords. NativeMethods.POINT gripLocation; if (RightToLeft == RightToLeft.Yes) { gripLocation = new NativeMethods.POINT(SizeGripBounds.Left, SizeGripBounds.Bottom); } else { gripLocation = new NativeMethods.POINT(SizeGripBounds.Right, SizeGripBounds.Bottom); } UnsafeNativeMethods.MapWindowPoints(new HandleRef(this, this.Handle), rootHwnd, gripLocation, 1); int deltaBottomEdge = Math.Abs(rootHwndClientArea.bottom - gripLocation.y); int deltaRightEdge = Math.Abs(rootHwndClientArea.right - gripLocation.x); if (RightToLeft != RightToLeft.Yes) { if ((deltaRightEdge + deltaBottomEdge) < 2) { m.Result = (IntPtr)NativeMethods.HTBOTTOMRIGHT; return; } } } } } base.WndProc(ref m); }
protected override bool ProcessCmdKey(ref Message m, Keys keyData) { if (ToolStripManager.ModalMenuFilter.InMenuMode) { // ALT, then space should dismiss the menu and activate the system menu. if (keyData == Keys.Space) { // if we're focused it's ok to activate system menu // if we're not focused - we should not activate if we contain focus - this means a text box or something // has focus. if (Focused || !ContainsFocus) { NotifySelectionChange(null); Debug.WriteLineIf(ToolStrip.SnapFocusDebug.TraceVerbose, "[MenuStrip.ProcessCmdKey] Rolling up the menu and invoking the system menu"); ToolStripManager.ModalMenuFilter.ExitMenuMode(); // send a WM_SYSCOMMAND SC_KEYMENU + Space to activate the system menu. UnsafeNativeMethods.PostMessage(WindowsFormsUtils.GetRootHWnd(this), NativeMethods.WM_SYSCOMMAND, NativeMethods.SC_KEYMENU, (int)Keys.Space); return(true); } } } return(base.ProcessCmdKey(ref m, keyData)); }
protected override void WndProc(ref Message m) { if ((m.Msg == 0x84) && this.SizingGrip) { Rectangle sizeGripBounds = this.SizeGripBounds; int x = System.Windows.Forms.NativeMethods.Util.LOWORD(m.LParam); int y = System.Windows.Forms.NativeMethods.Util.HIWORD(m.LParam); if (sizeGripBounds.Contains(base.PointToClient(new Point(x, y)))) { HandleRef rootHWnd = WindowsFormsUtils.GetRootHWnd(this); if ((rootHWnd.Handle != IntPtr.Zero) && !System.Windows.Forms.UnsafeNativeMethods.IsZoomed(rootHWnd)) { System.Windows.Forms.NativeMethods.POINT point; System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetClientRect(rootHWnd, ref rect); if (this.RightToLeft == RightToLeft.Yes) { point = new System.Windows.Forms.NativeMethods.POINT(this.SizeGripBounds.Left, this.SizeGripBounds.Bottom); } else { point = new System.Windows.Forms.NativeMethods.POINT(this.SizeGripBounds.Right, this.SizeGripBounds.Bottom); } System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(this, base.Handle), rootHWnd, point, 1); int num3 = Math.Abs((int)(rect.bottom - point.y)); int num4 = Math.Abs((int)(rect.right - point.x)); if ((this.RightToLeft != RightToLeft.Yes) && ((num4 + num3) < 2)) { m.Result = (IntPtr)0x11; return; } } } } base.WndProc(ref m); }