设置闪烁的标题栏

实现效果:

  

知识运用:

  用到了API函数的FlashWindow

  [System.Runtime.InteropServices.DllImportAttribute("user32_.dll")]

  public static extern bool FlashWindow(IntPtr handle,bool bInvert);

  //handle: 表是要闪烁的窗体  bInvert: 是否恢复状态

实现代码:

        //重写API函数 用来实现标题栏的闪烁功能
        [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
        public static extern bool FlashWindow(IntPtr handle,bool bInvert);
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            FlashWindow(this.Handle, true);     //启动窗体闪烁函数
        }
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;          //启动计时器
        }
        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;         //关闭计时器
        }
原文地址:https://www.cnblogs.com/feiyucha/p/10101732.html