本文实例讲述了C# winform实现右下角弹出窗口结果的方法。分享给大家供大家参考,具体如下:
using System.Runtime.InteropServices; [DllImport(user32)] private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); //下面是可用的常量,按照不合的动画结果声明本身须要的 private const int AW_HOR_POSITIVE = 0 x0001;//自左向右显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记 private const int AW_HOR_NEGATIVE = 0 x0002;//自右向左显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记 private const int AW_VER_POSITIVE = 0 x0004;//自顶向下显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记 private const int AW_VER_NEGATIVE = 0 x0008;//自下向上显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记该标记 private const int AW_CENTER = 0 x0010;//若应用了AW_HIDE标记,则使窗口向内重叠;不然向外扩大 private const int AW_HIDE = 0 x10000;//隐蔽窗口 private const int AW_ACTIVE = 0 x20000;//激活窗口,在应用了AW_HIDE标记后不要应用这个标记 private const int AW_SLIDE = 0 x40000;//应用滑动类型动画结果,默认为迁移转变动画类型,当应用AW_CENTER标记时,这个标记就被忽视 private const int AW_BLEND = 0 x80000;//应用淡入淡出结果 private void Form1_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 Form1_FormClosing(object sender, FormClosingEventArgs e) { AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE); }