C# Windows always on top

  • Thread starter Thread starter linuxfedora
  • Start date Start date
L

linuxfedora

Hi All,

I have a question about how to make a windows always on top of other
windows except the messageBox.

If i use TopMost properties, when my main application pop up a
messsageBox, then it will be behide the top most windows and i cannot
click on the messageBox easily.

Does anyone know how to solve this problem?THanks

Best regards,
FAI
 
I have a question about how to make a windows always on top of other
windows except the messageBox.

If i use TopMost properties, when my main application pop up a
messsageBox, then it will be behide the top most windows and i cannot
click on the messageBox easily.

Does anyone know how to solve this problem?THanks

You mean you want the window to always be on top of all other programs,
not just topmost in the program?

I would look at calling Win32 library function SetForeGroundWindow. Note
that this can get very annoying. If this is an errant user, I would
consider training prior to making the application always go to the top.
I, personally, get annoyed when something forces me to use it or kill
it, as it is taking up prime real estate on my screen.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Well, you could disable topmost for the duration of the MessageBox

private void ShowMessage(string message)
{
TopMost = false;
Application.DoEvents();
MessageBox.Show(message);
TopMost = true;
}
 
Thanks, it works.

Well, you could disable topmost for the duration of the MessageBox

        private void ShowMessage(string message)
        {
            TopMost = false;
            Application.DoEvents();
            MessageBox.Show(message);
            TopMost = true;
        }

--
Happy Coding!
Morten Wennevik [C# MVP]

linuxfedora said:
I have a question about how to make a windows always on top of other
windows except the messageBox.
If i use TopMost properties, when my main application pop up a
messsageBox, then it will be behide the top most windows and i cannot
click on the messageBox easily.
Does anyone know how to solve this problem?THanks
Best regards,
FAI
.
 
Back
Top