Reputation: 1
I'm scratching my head on this one. A user turned in a bug report that when they resize the form by double clicking the header the tool strip menu item that moves under the mouse is clicked.
I've isolated it to the tool strip menu item being under the mouse by creating a new .NET project with a WinForms .NET form > Adding a MenuStrip > Adding a ToolStripMenuItem > setting the click on the ToolStripMenuItem to a popup box saying that it was clicked.
When I move the form so my mouse will be over the ToolStripMenuItem when the form resizes, then double click the header, the form goes full screen and I get the popup that I clicked the ToolStripMenuItem.
If I replace the MenuStrip with a button the issue does not reproduce.
Any idea how to fix this short of adding a DateTime for the last refresh and updating all the ToolStripMenuItem click events to not process clicks within 100ms of the form resizing?
public partial class Form1 : Form
{
private DateTime _doNotClickMenuItemsUntil = DateTime.MinValue;
public Form1()
{
InitializeComponent();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
if (DateTime.Now > _doNotClickMenuItemsUntil)
MessageBox.Show("toolStripMenuItem1_Click!");
}
private void Form1_Resize(object sender, EventArgs e)
{
_doNotClickMenuItemsUntil = DateTime.Now.AddMinutes(100);
}
}
Upvotes: 0
Views: 114