문제

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?

도움이 되었습니까?

해결책

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();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top