FlashWindowEx實現視窗在工作列閃爍/變化顏色

來源:互聯網
上載者:User
 代碼如下 複製代碼

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");
 }
 


方法二:

 代碼如下 複製代碼


<html>  
   
  <head>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">  
  <meta   name="GENERATOR"   content="Microsoft   FrontPage   4.0">  
  <meta   name="ProgId"   content="FrontPage.Editor.Document">  
  <title>工作列閃動</title>  
  <script   language=javascript>  
  function   splashwin()  
  {  
  document.all.min.Click();  
  window.resizeTo(0,0);  
  window.moveTo(9000,9000)  
  window.focus();  
  window.blur();  
   
  setTimeout("splashwin()",10);  
  }  
  </script>  
  </head>  
   
  <body   onload="window.resizeTo(0,0);window.moveTo(9000,9000);splashwin();">  
  <OBJECT   id="min"   type="application/x-oleobject"   classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">  
  <PARAM   name="Command"   value="Minimize">  
  </OBJECT>  
  </body>  
  </html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.