From 8bf5c1878b0eb1b73618db019e641d9084302d44 Mon Sep 17 00:00:00 2001 From: orapps44 <77468294+orapps44@users.noreply.github.com> Date: Mon, 18 Oct 2021 22:32:45 +0200 Subject: [PATCH] Fix dual ContextMenuStrip when right click on form Statusbar Fix dual ContextMenuStrip when right click on form Statusbar --- MaterialSkin/Controls/MaterialForm.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MaterialSkin/Controls/MaterialForm.cs b/MaterialSkin/Controls/MaterialForm.cs index a1d32e38..fcf4726e 100644 --- a/MaterialSkin/Controls/MaterialForm.cs +++ b/MaterialSkin/Controls/MaterialForm.cs @@ -833,11 +833,18 @@ protected override void WndProc(ref Message m) if (_statusBarBounds.Contains(cursorPos) && !_minButtonBounds.Contains(cursorPos) && !_maxButtonBounds.Contains(cursorPos) && !_xButtonBounds.Contains(cursorPos)) { + // Temporary disable user defined ContextMenuStrip + var user_cms = base.ContextMenuStrip; + base.ContextMenuStrip = null; + // Show default system menu when right clicking titlebar var id = TrackPopupMenuEx(GetSystemMenu(Handle, false), (int)TPM.LeftAlign | (int)TPM.ReturnCommand, Cursor.Position.X, Cursor.Position.Y, Handle, IntPtr.Zero); // Pass the command as a WM_SYSCOMMAND message SendMessage(Handle, (int)WM.SystemCommand, id, 0); + + // restore user defined ContextMenuStrip + base.ContextMenuStrip = user_cms; } } }