tags:

views:

158

answers:

2

I feel like I'm commiting a cardinal sin by asking how to do this becuase in most instances it would be wrong and evil. But...

I have a winforms app that minimises to the systray when not being used I want to make it pop up and be the topmost window when it recieves a message from a server.

I can make it appear, but I can't get it to be the topmost window. (Setting topmost doesn't change it, but it does make it topmost once it's gained focus)

Does anyone know how to do this?, I wouldn't normally do this but a client has asked for this behavious so I have to implement it... :(

+1  A: 

If .Net's 'topmost' thing is not working, you may try getting this service directly from the 'SetWindowPos()' API of Windows. See this page for details.

Frederick
+1  A: 

There is a post around this issue on Microsoft's forums.

Normally, if the window is in your app, calling its BringToFront method should do the trick.

So normal order of operations:

  1. make it visible
  2. call BringToFront()
  3. Set it TopMost
Denis Troller
That doesn't work if your whole app is minimised, it probably only works if one of your own windows currently has focus.
Omar Kooheji