zoukankan      html  css  js  c++  java
  • C# Winform右下角弹窗方式

    【方法一】

    第一步:winform项目创建完成后,添加一个窗口,命名为:Messages 。(加上最开始的Form1,一共为两个窗口),双击主窗口进入后台代码 。

    第二步:在Messages 窗口中添加一个 timer 时钟,修改一下属性,将 Enabled 属性改为 True ;Interval 属性修改为1000(这是修改窗体弹出时间时的速度,)。

    第三步:选择事件按钮,双击进入代码界面,具体代码如下:

    private void timer1_Tick(object sender, EventArgs e)
    {
    timer1.Enabled = false;
    for (int i = 0; i <= this.Height; i++)
    {
    Point p = new Point(this.Location.X, this.Location.Y + i);//弹出框向下移动消失
    this.PointToScreen(p);//即时转换成屏幕坐标
    this.Location = p;// new Point(this.Location.X, this.Location.Y + 1);
    System.Threading.Thread.Sleep(10);//下降速度调节,数字越小消失的速度越快,建议不大于10
    }
    this.Close();
    this.Dispose();
    }

    第四步:返回主程序(Form1),双击窗体,添加代码如下:

    private void Form1_Load(object sender, EventArgs e)
    {
    Messages msg = new Messages();//将窗口Messages 实例化
    Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - msg.Width, Screen.PrimaryScreen.WorkingArea.Height);
    msg.PointToClient(p);
    msg.Location = p;
    msg.Show();
    for (int i = 0; i < msg.Height; i++)
    {
    msg.Location = new Point(p.X, p.Y - i);
    System.Threading.Thread.Sleep(1);//消息框弹出速度,数值越大越慢
    }
    }

  • 相关阅读:
    HTML Rendering Error
    PyCharm将选中的内容加上引号
    Scrapy中的Request和日志分析
    PyCharm关闭按两次Shift进入搜索框的功能
    博客园更换模板的链接
    Scrapy的Spider类和CrawlSpider类
    Scrapy安装和简单使用
    计算π的近似值
    Python用pip安装第三方库时换源下载
    网页解析 -- bs4 和 xpath 的简单使用
  • 原文地址:https://www.cnblogs.com/gzh-1019/p/7979154.html
Copyright © 2011-2022 走看看