Howto use NotifyIcon single click to bring form in front?

M

Marcel Brekelmans

Hello,

I have an application with a notifyIcon. When my application's main form is
hidden by some other window I would like to bring it in front by
single-clicking the NotifyIcon. However, I can't get it done. In the Click
event I've used all sorts of methods:

this.SetTopLevel(true);
this.Show();
this.Focus();
this.BringToFront();

When I try it with my application's form focused, I see that it just loses
its focus! I guess that's because the click on the NotifyIcon shifts focus
to that NotifyIcon. But how can I bring my app's form to front, give it
focus again?

Thanks!
 
T

Tom Porterfield

Marcel said:
I have an application with a notifyIcon. When my application's main form
is hidden by some other window I would like to bring it in front by
single-clicking the NotifyIcon. However, I can't get it done. In the Click
event I've used all sorts of methods:

this.SetTopLevel(true);
this.Show();
this.Focus();
this.BringToFront();

When I try it with my application's form focused, I see that it just loses
its focus! I guess that's because the click on the NotifyIcon shifts focus
to that NotifyIcon. But how can I bring my app's form to front, give it
focus again?

this.Activate() is what you are looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top