user34537
user34537

Reputation:

How do i set this window to topmost?

How do i set my window above all other? I need a bad but noticeable msg box that closes on its own. Msg is a dummy form which is empty. All i want is its title. The problems with the code is the window isnt created 0,0 (its just whereever windows feels like putting it). The width is correct but i notice if i click firefox or another app window my app doesnt pop up. I know it is being shown bc i can see it in the taskbar at the bottom for a brief second. So the bugs so far

  1. Doesnt go topmost if i click another app
  2. Isnt 0,0

How do i fix this?

            {
                var msg = new Msg();
                msg.Text = (has ? "*" : "+") + args[0];
                msg.TopMost = true;
                msg.Width = 2000;
                msg.Top = 0;
                msg.Left = 0;
                msg.Show();
                System.Threading.Thread.Sleep(1000);
                msg.Close();
            }

Upvotes: 1

Views: 283

Answers (1)

STW
STW

Reputation: 46394

Sounds like TopMost doesn't always do it; here's an answer to a similar question showing how to hook into Win32 for the call: Form top most?


Update: just read the rest of the answer; it might only fail running in Debug mode within Visual Studio (where your app is actually executed with vshost.exe, rather than running independently).

Upvotes: 2

Related Questions