winform窗体显示在右下角-10分钟显示一次

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

 

namespace DMGY
{
    public partial class DealMsg : Form

    {

        private static DealMsg dealMsg;  //静态对象

        private bool finished = false; //设置  
        private int screenWidth;//屏幕宽度  
        private int screenHeight;//屏幕高度 

 

 

       public DealMsg()
        {
            InitializeComponent();
            // this.empSet = empSet;

        }

 

        /// <summary>
        /// 窗体关闭-关闭时慢慢消失
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnQuit_Click(object sender, EventArgs e)
        {
            finished = true;
        }

 

        /// <summary>
        ///  运行
        /// </summary>
        internal static void Run()
        {
              //获得客户列表
             if (dealMsg==null || dealMsg.IsDisposed)
                 dealMsg = new DealMsg();
             dealMsg.Show();
            //显示信息
        }

 

        ///窗体加载

         private void DealMsg_Load(object sender, EventArgs e)
        {
            screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
            screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
            //设置提示窗口坐标在屏幕可显示区域之外 
            this.SetDesktopLocation(screenWidth-this.Width, screenHeight-this.Height);
            DataBind();
            timer.Start();
        }

 

        ///定时器 用于慢慢消失窗体
        private void timer_Tick(object sender, EventArgs e)
        {
            if (!finished)
            //如果提示窗口没有完全显示 
            {
                //如果提示窗口的纵坐标与提示窗口的高度之和大于屏幕高度  
                if (Location.Y + Height >= screenHeight)
                {
                    Location = new Point(Location.X, Location.Y - 2);
                   // this.SetDesktopLocation(screenWidth, screenHeight-1);
                }
            }
            else
            //如果提示窗口已经完成了显示,并且点击了确定按钮
            {
                //如果提示窗口没有完全从屏幕上消失  
                if (Location.Y < screenHeight)
                {
                    Location = new Point(Location.X, Location.Y + 2);
                    //this.SetDesktopLocation(screenWidth, screenHeight + 1);
                }
                else
                {
                    this.Close();
                    timer.Stop();
                }
            }
        }

      

    }

}

 

///主窗体

namespace DMGY

{

     public partial class frmMain : Form

     {

         ///控制定时器10分显示一次消息

         private void TimerInfo_Tick(object sender, EventArgs e)
        {
            DealMsg.Run();
            TimerInfo.Interval = 10 * 60*1000;//10分钟 提醒一次
        }

     }

 

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值