c# 右下角弹窗提示

网上方法总结

第一种:AnimateWindow窗口动画

优点:淡入效果好

缺点:窗口完全出现后才开始绘制上面的控件,效果不好。

/// <summary>  
/// 窗体动画函数    注意:要引用System.Runtime.InteropServices;  
/// </summary>  
/// <param name="hwnd">指定产生动画的窗口的句柄</param>  
/// <param name="dwTime">指定动画持续的时间</param>  
/// <param name="dwFlags">指定动画类型,可以是一个或多个标志的组合。</param>  
/// <returns></returns>
      [DllImport("user32")]  
      private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);  
      //下面是可用的常量,根据不同的动画效果声明自己需要的  
      private const int AW_HOR_POSITIVE = 0x0001;//自左向右显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志  
      private const int AW_HOR_NEGATIVE = 0x0002;//自右向左显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志  
      private const int AW_VER_POSITIVE = 0x0004;//自顶向下显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志  
      private const int AW_VER_NEGATIVE = 0x0008;//自下向上显示窗口,该标志可以在滚动动画和滑动动画中使用。使用AW_CENTER标志时忽略该标志该标志  
      private const int AW_CENTER = 0x0010;//若使用了AW_HIDE标志,则使窗口向内重叠;否则向外扩展  
      private const int AW_HIDE = 0x10000;//隐藏窗口  
      private const int AW_ACTIVE = 0x20000;//激活窗口,在使用了AW_HIDE标志后不要使用这个标志  
      private const int AW_SLIDE = 0x40000;//使用滑动类型动画效果,默认为滚动动画类型,当使用AW_CENTER标志时,这个标志就被忽略  
      private const int AW_BLEND = 0x80000;//使用淡入淡出效果  
  
  
      private void FrmMsg_Load(object sender, EventArgs e)  
      {  
          int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width;  
          int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;  
          this.Location = new Point(x, y);//设置窗体在屏幕右下角显示  
          AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE);  
      }  
      private void FrmMsg_FormClosing(object sender, FormClosingEventArgs e)  
      {  
          AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE);  
      }
参考:
C# winform 窗体从右下角向上弹出窗口效果
C#简单实现渐显弹出消息在"右下角"显示(Demo)
Winform 屏幕右下角弹出提示窗口
 

第二种:自己绘制动画

这种方法通过不断Refresh窗体,可以保证窗体上面控件的一直显示:

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            //窗体飞入过程
            Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - form2.Width, Screen.PrimaryScreen.WorkingArea.Height);
            form2.PointToScreen(p);
            form2.Location = p;
            form2.Show();
            for (int i = 0; i <= form2.Height; i++)
            {
                form2.Location = new Point(p.X, p.Y - i);
                form2.Refresh();//刷新窗体
                Thread.Sleep(5);
            }
        }

方法案例: winform C#屏幕右下角弹出消息框,自动消失

原文地址:https://www.cnblogs.com/GISRSMAN/p/4762659.html