2017-01-01 29 views
-2

我正在研究這個具有相當小UI的應用程序。 315 x 340. 當我最小化它時,它會在任務欄右下角提示氣球提示。如何讓我的應用程序從右下角開始?

當我單擊任務欄中的notifyIcon時,我希望應用程序在右下角打開屏幕,無論是什麼屏幕分辨率即時通訊。 我會假設這是基於項目設置,而不是代碼相關。

如何使應用程序從屏幕右下角開始?

回答

3

設置窗體的StartPositionManual。然後,您可以使用Screen對象獲取工作區域(與任務欄,應用欄等分辨率不同),並設置相應的位置,例如

protected override void OnLoad(EventArgs e) 
{ 
    int x; 
    int y; 
    Screen screen; 

    base.OnLoad(e); 

    screen = Screen.PrimaryScreen; 
    x = screen.WorkingArea.Right - this.Width; 
    y = screen.WorkingArea.Height - this.Height; 

    this.Location = new Point(x, y); 
} 
1

根據是否Windows窗體或WPF:

WinForms: Setting the Screen Location of a Window

public Form1() 
{ 
    InitializeComponent(); 
    StartPosition = FormStartPosition.Manual; 
    Rectangle area = Screens.Primary.WorkingArea; 
    Location = new Point(area.Width-315, area.Height-340); 
} 

在WPF中,這是非常相似的。

public Window1() 
{ 
    InitializeComponent(); 
    WindowStartupLocation = WindowStartupLocation.Manual; 
    Rectangle area = Screens.Primary.WorkingArea; 
    Left = area.Width-315; 
    Top = area.Height-340; 
} 
相關問題