码迷,mamicode.com
首页 > Windows程序 > 详细

WinForm 窗体闪烁 & 任务栏提示

时间:2016-03-23 17:00:07      阅读:366      评论:0      收藏:0      [点我收藏+]

标签:

准备:

 1 [DllImport("user32.dll")]
 2 static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
 3 
 4 [DllImport("user32.dll")]
 5 static extern bool FlashWindow(IntPtr handle, bool invert);
 6 
 7 [StructLayout(LayoutKind.Sequential)]
 8 public struct FLASHWINFO
 9 {
10     public UInt32 cbSize;
11     public IntPtr hwnd;
12     public UInt32 dwFlags;
13     public UInt32 uCount;
14     public UInt32 dwTimeOut;
15 }
16 
17 public const UInt32 FLASHW_STOP = 0x00000000;
18 public const UInt32 FLASHW_CAPTION = 0x00000001;
19 public const UInt32 FLASHW_TRAY = 0x00000002;
20 public const UInt32 FLASHW_ALL = 0x00000003;
21 public const UInt32 FLASHW_TIMER = 0x00000004;
22 public const UInt32 FLASHW_TIMERNOFG = 0x0000000C

事件

 1 private void button1_Click(object sender, EventArgs e)
 2 {
 3   //闪烁
 4   FLASHWINFO fi = new FLASHWINFO();
 5 
 6   fi.cbSize = (uint)Marshal.SizeOf(fi);
 7   fi.hwnd = this.Handle;
 8   fi.dwFlags = FLASHW_TIMER | FLASHW_ALL;
 9   fi.uCount = 5;
10   fi.dwTimeOut = 75;
11 
12   FlashWindowEx(ref fi);
13 }
14 
15 private void button2_Click(object sender, EventArgs e)
16 {
17     //任务栏消息提示
18     this.WindowState = FormWindowState.Minimized;
19     FlashWindow(this.Handle, true);
20 }

 

WinForm 窗体闪烁 & 任务栏提示

标签:

原文地址:http://www.cnblogs.com/lztwj/p/5311743.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!