views:

254

answers:

1

In my application (C', Windows Forms) I have got a telephone information screen: if there is an incoming phone call a window with additional information to the caller is shown.

This window should open in foreground and should stay there even if the user is writing in another window (so the user still sees the information regarding the incoming phone call).

First I've used BringToFront - but this didn't really work in all circumstances (e.g. when the main application was not in the foreground).

Right now I am using BringToFront and the user32.dll function BringWindowToTop -> which works, but if the window loses focus it is in the background.

How do I implement this behaviour ?

+7  A: 

I think you want to set your form as TopMost:

yourForm.TopMost = true;
CMS
TopMost: Gets or sets a value that indicates whether a window appears in the topmost z-order. So nope, that ain't it, when you want the form to stay on top when you lose focus.
tzup
@tzup: toss together a little sample project and try it out. You're in for a surprise...
Fredrik Mörk
doing it right now :) ...
tzup
Works for me - thank you...
bernhardrusch
@CMS, you're right ... darn it ... I think I read that question too fast. That ought to teach me!
tzup