zoukankan      html  css  js  c++  java
  • 类似qq弹窗,自动消失

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace FormCPM
    {
        public partial class Form1 : Form
        {
            const int countDown = 60;//倒计时
            int currCountDown = countDown;//倒计时
            bool isCount = true;
            Thread thread;
            public Form1()
            {
                InitializeComponent();
                thread = new Thread(() =>
                {
                    while (true)
                    {
                        if (isCount)
                        {
                            if (currCountDown <= 0)
                            {
                                this.Invoke(new Action(() =>
                                {
                                    this.Close();
                                }));
                                break;
                            }
                            else
                            {
                                Thread.Sleep(100);
                                currCountDown--;
                                this.Invoke(new Action(() =>
                                {
                                    this.Opacity = this.Opacity - this.Opacity / countDown;
                                }));
    
                            }
                        }
                        else
                        {
                            Thread.Sleep(10);
                        }
                    }
                });
                thread.IsBackground = true;
            }
            [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 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);
                thread.Start();
    
            }private void Form1_MouseEnter(object sender, EventArgs e)
            {
                isCount = false;
                currCountDown = countDown;
    this.Opacity = 1d;
    }
    private void Form1_MouseLeave(object sender, EventArgs e) { isCount = true; } } }
  • 相关阅读:
    ColorPix——到目前为止最好用的屏幕取色器
    ES+VBA 实现批量添加网络图片
    SQL语句-delete语句
    Visual C++ 2013 and Visual C++ Redistributable Package 更新版官网下载地址
    centos长ping输出日志的脚本
    Centos 常用命令
    c#连接数据库
    C#窗体间的跳转传值
    c#邮件发送
    C#WIFI搜索与连接
  • 原文地址:https://www.cnblogs.com/rexfieBlogs/p/4663008.html
Copyright © 2011-2022 走看看