Skip to content

Commit

Permalink
Merge pull request #246 from leocb/orapps44-form-ContextMenuStrip
Browse files Browse the repository at this point in the history
Fix dual ContextMenuStrip when right click on form Statusbar
  • Loading branch information
orapps44 committed Oct 18, 2021
2 parents 366644c + 8bf5c18 commit 951b4ad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions MaterialSkin/Controls/MaterialForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 951b4ad

Please sign in to comment.