WinForm 窗体闪烁 & 任务栏提示
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WinForm 窗体闪烁 & 任务栏提示相关的知识,希望对你有一定的参考价值。
准备:
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 窗体闪烁 & 任务栏提示的主要内容,如果未能解决你的问题,请参考以下文章
C# Winform WPF DeskBand 窗体嵌入任务栏,在任务栏显示文字