Reputation: 15138
I want to pop up a form in C# .net 2.0 which should be in front of the desktop (topmost) until the user clicks the close button.
How to do so?
I tried the code from here: http://dotnet-snippets.de/dns/fenster-wirklich-in-den-vordergrund-des-desktops-bringen-SID1005.aspx
But it didn't work. My system is Win7.
Upvotes: 3
Views: 678
Reputation: 11104
Code below will create MessageBox with TopMost property making it on Top until user clicks No or Yes.
DialogResult result = DialogResult.No;
try {
result = MessageBox.Show(new Form {
TopMost = true, MinimizeBox = false,
}, "some text", "some topic", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
} finally {
if (result == DialogResult.No) {
}
}
Upvotes: 3
Reputation: 16505
Set the form's TopMost property to true and MinimizeBox property to false.
Upvotes: 4