Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to show a winform in the very right down corner just above the system tray,

How do I do that? Here is my code:

public static void Notify()
{        
    Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
    Form fm = new Form();
    fm.ClientSize = new Size(200, 200);
    int left = workingArea.Width - fm.Width;
    int top = workingArea.Height - fm.Height;
    fm.Location = new Point(left, top);
    fm.ShowInTaskbar = false;
    fm.ShowIcon = false;
    fm.MinimizeBox = false;
    fm.MaximizeBox = false;
    fm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
    fm.Text = "Test";
    fm.TopMost = true;
    fm.Show();
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
362 views
Welcome To Ask or Share your Answers For Others

1 Answer

I just tried this and it worked for me (note: this code must appear after the form has been displayed for the first time -- for example, you can put it in the form's Load event handler, or simply include it after any call to Show):

Rectangle workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
int left = workingArea.Width - this.Width;
int top = workingArea.Height - this.Height;

this.Location = new Point(left, top);

Whether to use WorkingArea or Bounds depends on what you mean by "over": if you mean "in front of," then use Bounds, as it includes the area covering the entire screen (including that space occupied by the system tray); if you mean "above," then use WorkingArea, which just includes the user's desktop.

Also let me just clarify that you want your actual form displayed down there, right? If you wanted an icon in the notification area, that's what the NotifyIcon component is for.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...