当前位置: 首页 > news >正文

大货车找事做下载怎么网站深圳债务优化公司

大货车找事做下载怎么网站,深圳债务优化公司,时时彩网站代理怎么做,忂州网站建设前言 消息通知在应用程序中,是一种非常有用的功能,实现对一些重要信息、提醒或警告及时向用户展示。我们在使用软件时,通常会收到一种从桌面右下角弹出的(提示信息或广告)信息框。本文将介绍使用 C# 实现此种方式的信息…

前言

消息通知在应用程序中,是一种非常有用的功能,实现对一些重要信息、提醒或警告及时向用户展示。我们在使用软件时,通常会收到一种从桌面右下角弹出的(提示信息或广告)信息框。本文将介绍使用 C# 实现此种方式的信息通知窗口。

实现

1、使用 API 的 AnimateWindow 函数

定义 AnimateWindows

using System;using System.Runtime.InteropServices;
namespace Fountain.WinForm.MessageBoxDemo{    public class Win32    {        /// <summary>        /// 自左向右显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记        /// </summary>        public const int AW_HOR_POSITIVE = 0x0001;        /// <summary>        /// 自右向左显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记        /// </summary>        public const int AW_HOR_NEGATIVE = 0x0002;        /// <summary>        /// 自顶向下显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记        /// </summary>        public const int AW_VER_POSITIVE = 0x0004;        /// <summary>        /// 自下向上显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记该标记        /// </summary>        public const int AW_VER_NEGATIVE = 0x0008;        /// <summary>        /// 若应用了AW_HIDE标记,则使窗口向内重叠;不然向外扩大        /// </summary>        public const int AW_CENTER = 0x0010;        /// <summary>        /// 隐蔽窗口        /// </summary>        public const int AW_HIDE = 0x10000;        /// <summary>        /// 激活窗口,在应用了AW_HIDE标记后不要应用这个标记        /// </summary>        public const int AW_ACTIVE = 0x20000;        /// <summary>        /// 滑动类型动画结果,默认为迁移转变动画类型,当应用AW_CENTER标记时,这个标记就被忽视        /// </summary>        public const int AW_SLIDE = 0x40000;        /// <summary>        /// 淡入淡出结果        /// </summary>        public const int AW_BLEND = 0x80000;        /// <summary>        /// 窗体动画函数        /// </summary>        /// <param name="hwnd"></param>        /// <param name="dwTime"></param>        /// <param name="dwFlags"></param>        /// <returns></returns>        [DllImport("user32")]        public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);    }}

定义显示消息窗体

using System;using System.Drawing;using System.Windows.Forms;
namespace Fountain.WinForm.MessageBoxDemo{    public partial class FormMessageBox : Form    {        /// <summary>        /// 关闭窗口的定时器        /// </summary>        private Timer formCloseTime = new Timer();        /// <summary>        /// 构造方法        /// </summary>        public FormMessageBox()        {            InitializeComponent();        }        /// <summary>        /// 窗体加载        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void FormMessageBox_Load(object sender, EventArgs e)        {            // 手动设置起始位置            this.StartPosition = FormStartPosition.Manual;            // 计算屏幕尺寸并将窗体放置在右下角            Rectangle screenRectangle = Screen.PrimaryScreen.WorkingArea;            int x = screenRectangle.Width - this.Width;            int y = screenRectangle.Height - this.Height;            this.Location = new Point(x, y);            this.TopMost = true;
            Win32.AnimateWindow(this.Handle, 1000, Win32.AW_SLIDE + Win32.AW_VER_NEGATIVE);
            this.ShowInTaskbar = false;
            formCloseTime.Interval = 5000;            formCloseTime.Tick += new EventHandler(formCloseTime_Tick);            formCloseTime.Start();        }        /// <summary>        /// 关闭窗口的定时器响应事件        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void formCloseTime_Tick(object sender, EventArgs e)        {            formCloseTime.Stop();            this.Close();        }        /// <summary>        ///         /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void FormMessageBox_FormClosed(object sender, FormClosedEventArgs e)        {            formCloseTime.Stop();            formCloseTime.Dispose();            Win32.AnimateWindow(this.Handle, 1000, Win32.AW_SLIDE + Win32.AW_VER_POSITIVE + Win32.AW_HIDE);        }    }}

主界面调用

FormMessageBox formMessageBox = new FormMessageBox();formMessageBox.Show();

2、控制窗体显示

定义显示消息窗体

using System;using System.Drawing;using System.Threading;using System.Windows.Forms;
namespace Fountain.WinForm.MessageBoxDemo{    public partial class FormNotifyBox : Form    {        /// <summary>        /// 关闭窗口的定时器        /// </summary>        private System.Windows.Forms.Timer formCloseTime = new System.Windows.Forms.Timer();        /// <summary>        ///         /// </summary>        private Point formPoint;        /// <summary>        ///         /// </summary>        public FormNotifyBox()        {            InitializeComponent();            this.formPoint = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height);            // 设置窗体在屏幕右下角显示            this.Location = formPoint;        }        /// <summary>        ///         /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void FormNotifyBox_Load(object sender, EventArgs e)        {            try            {                formCloseTime.Interval = 5000;                formCloseTime.Tick += new EventHandler(formCloseTime_Tick);                formCloseTime.Start();                this.TopMost = false;                this.BringToFront();                this.TopMost = true;                this.PointToClient(this.formPoint);                this.Location = this.formPoint;                this.Show();                for (int i = 0; i < this.Height; i++)                {                    this.Location = new Point(formPoint.X, formPoint.Y - i);                    // 消息框弹出速度,数值越大越慢                    Thread.Sleep(1);                }            }            catch (Exception exception)            {               }        }        /// <summary>        /// 关闭窗口的定时器响应事件        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void formCloseTime_Tick(object sender, EventArgs e)        {            formCloseTime.Enabled = false;            for (int i = 0; i <= this.Height; i++)            {                //弹出框向下移动消失                Point point = new Point(this.Location.X, this.Location.Y + i);                this.PointToScreen(point);                //即时转换成屏幕坐标                this.Location = point;                //下降速度调节,数字越小消失的速度越快,建议不大于10                Thread.Sleep(8);            }            this.Close();            this.Dispose();        }    }}

主界面调用

FormNotifyBox notifyForm = new FormNotifyBox();notifyForm.Show();
http://www.ds6.com.cn/news/65231.html

相关文章:

  • 跨境电商网站建设百度问一问客服人工在线咨询
  • 专业营销网站建设网站页面设计模板
  • 网站怎么做3d商品浏览申请域名
  • 梅州网站建设求职简历如何找推广平台
  • html5开发网站亚马逊seo关键词优化软件
  • 曲靖市建设局网站2022网站seo
  • 黄石网站建设公司赣州seo推广
  • 企业网站推广方案网络营销作业山东今日热搜
  • 网上做兼职网站正规seo网站设计
  • 南昌网站建设培训学校网络seo是什么意思
  • 合肥 网站建设网络营销专业如何
  • 固始网站建设seo引擎优化服务
  • 为什么网站搜索不到seo效果检测步骤
  • 电影网站建设多少钱网站在线生成app
  • 通付盾 建设网站手机怎么自己制作网页
  • 网页设计素材免费版seo高效优化
  • 合肥墙面刷新长沙网站优化培训
  • 论坛网站开发百度怎么做网站
  • 小程序排行榜北京谷歌seo
  • 上海 有哪些做网站的公司百度用户服务中心客服电话
  • 政务网站建设规范建网站怎么建
  • 网站设计页面近三天发生的重要新闻
  • 网站建设、百度推广首页关键词排名优化
  • wordpress 物流信息seo百度发包工具
  • iis6 建设网站浏览360营销
  • wordpress 响应式菜单seo排名技巧
  • 网站导航网线上职业技能培训平台
  • 门户网站建设 总结seo排名方案
  • 地方购物网站盈利模式智能营销系统开发
  • 亚马逊deal网站怎么做百度营销官网