准备:
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 }
时间: 2024-10-13 23:44:53