c#表单弹出位置

本文关键字:位置 出位 表单 | 更新日期: 2023-09-27 18:08:29

我正在构建一个弹出应用程序来显示一些通知。我想把它显示在屏幕的右下角,在任何分辨率下。屏幕尺寸为422 × 217(宽×高)。下面是我的代码:

private void Form1_Load(object sender, EventArgs e)
    {
        /*System.Windows.Forms.Timer MyTimer = new System.Windows.Forms.Timer(); */
        int num = 1;
        this.Hide();
        if (num == 1)
        {
            Form fm = new Form
            {
                Location = new Point(50, 60),
                StartPosition = FormStartPosition.Manual,
                ShowInTaskbar = false
            };
            fm.ShowDialog();
        }
    }

我想让弹出作为来自底部。有人能帮我一下吗?

c#表单弹出位置

我最近得到了一个'toaster'弹出代码,它从任何屏幕的右下角出来。下面是我使用的部分代码:

Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
            {
                var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
                var transform = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice;
                var corner = transform.Transform(new Point(workingArea.Right + 15, workingArea.Bottom - 10));
                this.Left = corner.X - this.ActualWidth - 100;
                this.Topmost = true;
                this.Top = corner.Y - this.ActualHeight;
            }));

根据您的"弹出"尺寸调整-100, +15-10