一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

FlashWindowEx实现窗口在任务栏闪烁/变化颜色

时间:2013-02-20 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码

using System;

 using System.Collections.Generic;

 using System.ComponentModel;

 using System.Data;

 using System.Drawing;

 using System.Linq;

 using System.Text;

 using System.Windows.Forms;

 using System.Runtime.InteropServices;

 namespace FlashWindowEX

 {

     public struct FLASHWINFO

     {

         public UInt32 cbSize;

         public IntPtr hwnd;

         public UInt32 dwFlags;

         public UInt32 uCount;

         public UInt32 dwTimeout;

     }
 

     public partial class Form1 : Form

     {

         public const UInt32 FLASHW_STOP = 0;

         public const UInt32 FLASHW_CAPTION = 1;

         public const UInt32 FLASHW_TRAY = 2;

         public const UInt32 FLASHW_ALL = 3;

         public const UInt32 FLASHW_TIMER = 4;

         public const UInt32 FLASHW_TIMERNOFG = 12;

         public Form1()

         {

             InitializeComponent();

         }

         [DllImport("user32.dll")]

         static extern bool FlashWindowEx(ref FLASHWINFO pwfi);

          [DllImport("user32.dll")]

         static extern bool FlashWindow(IntPtr handle, bool invert);

         private void button1_Click(object sender, EventArgs e)

         {

             this.WindowState = FormWindowState.Minimized;

 

             FLASHWINFO fInfo = new FLASHWINFO();

 

             fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));

             fInfo.hwnd = this.Handle;

             fInfo.dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG;//这里是闪动窗标题和任务栏按钮,直到用户激活窗体

             fInfo.uCount = UInt32.MaxValue;

             fInfo.dwTimeout = 0;

 

             FlashWindowEx(ref fInfo);

         }

     }

 }

下面附上js 任务栏闪动效果

方法一:

 代码如下 复制代码
setTimeout("setTitle1()","1000");
 
 function setTitle1()
 {
   document.title="标题";
   window.focus();
   setTimeout("setTitle2()","1000");
 }
 
 function setTitle2()
 {
  document.title="";
  setTimeout("setTitle1()","1000");
 }
 


方法二:

 代码如下 复制代码


  
   
    
    
    
    
  任务栏闪动  
    
  function   splashwin()  
  {  
  document.all.min.Click();  
  window.resizeTo(0,0);  
  window.moveTo(9000,9000)  
  window.focus();  
  window.blur();  
   
  setTimeout("splashwin()",10);  
  }  
    
    
   
    
    
    
    
    
 

热门栏目