How to save a window on top of all other windows only in my application?

I would like to display a status window in my C # Windows Forms application that informs the user when the application is waiting for a lock. This application is defined by the application, however, the window should be visible and always stay on top of all other windows of my application, even when the user clicks on another window (for example, the larger main window behind it).

It should not be modal (therefore, ShowDialog () cannot be used), because the application should continue to try in the background and automatically close the window if the lock can ultimately be obtained, and it really should not be the largest for the whole window station (i.e. all applications running in this terminal session).

I know the Form.TopMost property, but it can only display one window on top of all the others, even from other applications. This is clearly not what I am looking for.

I know that this is possible, I have seen this many times before in other applications. I just donโ€™t know how to do this.

+3
c # window topmost
Sep 08 '09 at 10:42
source share
2 answers

If you pass your main form to the Show status form method, it will remain on top of the main form, but not on top of other applications. So, in the main form, you can have this code:

 StatusForm statusForm = new StatusForm(); statusForm.Show(this); 

However, this will indicate only one window of your application as the owner.

+9
Sep 08 '09 at 10:46
source share
โ€” -

You must set the Owner property of the child form to the parent form and use Show to display the child form.

+4
Sep 08 '09 at 10:47
source share



All Articles