This is so annoying that I have to see if it's happened to anyone else and
see if I'm missing something well-known (I am not a WinForms expert).
Frequently, my form loses the ability to become active. This happens when
I'm debugging with VS.NET 2003 - I've been debugging for a while, so
wouldn't know whether it happens outside of the debugger.
It happened just now when I maximized the form. It maximized just fine, but
changed appearance to look inactive, and in fact was inactive. Clicking on
any part of the form doesn't change anything. Mousing over a top-level menu
item highlights it, but clicking on it does nothing. Mousing over the Close,
Minimize and Maximize buttons highlights them as well, but clicking does
nothing.
Right-clicking the notification icon shows the correct menu, and I can
minimize, maximize and restore. None of those makes the form active.
Clicking in the body of the form seems to make the form caption flash
briefly, but nothing happens.
Now, the one thing I'm doing that's a bit unusual is that I'm hosting
several one of several user controls in a panel in the middle of the form. I
_did_ have a problem with these. I had meant to remove and Dispose the old
user control before adding the new one, but that didn't work:
public static void ShowControl(Control control, Control container)
{
System.Collections.ArrayList disposeList =
new System.Collections.ArrayList();
foreach (Control old in container.Controls)
{
disposeList.Add(old);
}
foreach (Control toDispose in disposeList)
{
container.Controls.Remove(toDispose);
if (!toDispose.IsDisposed)
{
//toDispose.Dispose(); // This crashed. I forget the exception.
}
}
control.Dock = DockStyle.Fill;
control.Size = container.Size;
container.Controls.Add(control);
control.Show();
control.BringToFront();
}
Maybe this is catching up with me.
Any suggestions? Every time this happens I have to start over. The only way
I can close the form is through "End Process" in Task Manager!
-----
John Saunders