I have a WinForms application containing a ToolStrip with ToolStripButtons. Some of the button actions disable the main form while the button action takes place and re-enable it when finished. This is done to make sure the user does not click on other places while the action takes place, and also shows a WaitCursor but that's not relevant to the issue.
If the user clicks on the button and moves the mouse cursor outside of its bounds while the form is disabled, the button remains highlighted (transparent blue) even when re-enabling the form at a later point. If the mouse enter/leaves the button afterwards it is displayed correctly again.
I could artificially replicate the problem by showing a MessageBox using the following code (the actual action does not show a message box, but opens a new form and populates a grid, but the net effect is the same).
Here is a code snippet to replicate the issue:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
// Disable the form
Enabled = false;
// Some action where the user moved the mouse cursor to a different location
MessageBox.Show(this, "Message");
// Re-enable the form
Enabled= true;
}
}