Frage

When I double-click on my application icon like this, I want to get focus on the application. I've tried this:

private void noi_MouseDoubleClick(object sender, MouseEventArgs e)
{
    BringToFront();
    Focus();
}

But somehow it doesn't work. Any ideas?

War es hilfreich?

Lösung

BringToFront() doesn't do what you hope it does, it only arranges windows owned by the same application. To get in front of windows owned by other applications you need to use Activate() instead. Which often fails, you can't steal the focus away, but not a problem when you click on a NotifyIcon you own. Fix:

private void noi_MouseDoubleClick(object sender, MouseEventArgs e)
{
    Activate();
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top