WPF 任务栏图标闪烁提醒
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Interop; public static class FlashWindow
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FlashWindowEx(ref FLASHWINFO pwfi); [StructLayout(LayoutKind.Sequential)]
private struct FLASHWINFO
{
/// <summary>
/// The size of the structure in bytes.
/// </summary>
public uint cbSize; /// <summary>
/// A Handle to the Window to be Flashed. The window can be either opened or minimized.
/// </summary>
public IntPtr hwnd; /// <summary>
/// The Flash Status.
/// </summary>
public uint dwFlags; /// <summary>
/// The number of times to Flash the window.
/// </summary>
public uint uCount; /// <summary>
/// The rate at which the Window is to be flashed, in milliseconds. If Zero, the function uses the default cursor blink rate.
/// </summary>
public uint dwTimeout;
} /// <summary>
/// Stop flashing. The system restores the window to its original stae.
/// </summary>
public const uint FLASHW_STOP = ; /// <summary>
/// Flash the window caption.
/// </summary>
public const uint FLASHW_CAPTION = ; /// <summary>
/// Flash the taskbar button.
/// </summary>
public const uint FLASHW_TRAY = ; /// <summary>
/// Flash both the window caption and taskbar button.
/// This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
/// </summary>
public const uint FLASHW_ALL = ; /// <summary>
/// Flash continuously, until the FLASHW_STOP flag is set.
/// </summary>
public const uint FLASHW_TIMER = ; /// <summary>
/// Flash continuously until the window comes to the foreground.
/// </summary>
public const uint FLASHW_TIMERNOFG = ; /// <summary>
/// Flash the spacified Window (Form) until it recieves focus.
/// </summary>
/// <param name="form">The Form (Window) to Flash.</param>
/// <returns></returns>
public static bool Flash(Window w)
{
// Make sure we're running under Windows 2000 or later
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(new WindowInteropHelper(w).Handle, FLASHW_ALL | FLASHW_TIMERNOFG, uint.MaxValue, );
return FlashWindowEx(ref fi);
}
return false;
} private static FLASHWINFO Create_FLASHWINFO(IntPtr handle, uint flags, uint count, uint timeout)
{
FLASHWINFO fi = new FLASHWINFO();
fi.cbSize = Convert.ToUInt32(Marshal.SizeOf(fi));
fi.hwnd = handle;
fi.dwFlags = flags;
fi.uCount = count;
fi.dwTimeout = timeout;
return fi;
} /// <summary>
/// Flash the specified Window (form) for the specified number of times
/// </summary>
/// <param name="form">The Form (Window) to Flash.</param>
/// <param name="count">The number of times to Flash.</param>
/// <returns></returns>
public static bool Flash(Window w, uint count)
{
if (Win2000OrLater)
{
FLASHWINFO fi = Create_FLASHWINFO(new WindowInteropHelper(w).Handle, FLASHW_ALL, count, );
return FlashWindowEx(ref fi);
}
return false;
} /// <summary>
/// Start Flashing the specified Window (form)
/// </summary>
/// <param name="form">The Form (Window) to Flash.</param>
/// <returns></returns>
public static bool Start(Window w)
{
if (Win2000OrLater)
{
var fi = Create_FLASHWINFO(new WindowInteropHelper(w).Handle, FLASHW_ALL, uint.MaxValue, );
return FlashWindowEx(ref fi);
}
return false;
} /// <summary>
/// Stop Flashing the specified Window (form)
/// </summary>
/// <param name="form"></param>
/// <returns></returns>
public static bool Stop(Window w)
{
if (Win2000OrLater)
{
var fi = Create_FLASHWINFO(new WindowInteropHelper(w).Handle, FLASHW_STOP, uint.MaxValue, );
return FlashWindowEx(ref fi);
}
return false;
} /// <summary>
/// A boolean value indicating whether the application is running on Windows 2000 or later.
/// </summary>
private static bool Win2000OrLater
{
get { return System.Environment.OSVersion.Version.Major >= ; }
}
}
FlashWindow
启动:FlashWindow.Start(Window w);
停止:FlashWindow.Stop(Window w);
.NET技术交流群 199281001 .欢迎加入。
WPF 任务栏图标闪烁提醒的更多相关文章
- WPF 任务栏背景闪烁提醒
原文:WPF 任务栏图标闪烁提醒 public static class FlashWindow { [DllImport("user32.dll")] [return: Ma ...
- VC 任务栏图标闪烁
像QQ来消息时的,图标闪烁效果 将如下代码添加到Timer响应函数中 ) {// 任务栏图标闪烁 if (this != GetForegroundWindow()) { //// this-> ...
- WPF 系统托盘 图标闪烁
WPF消息通知 系统托盘,图标闪烁 using System.Windows.Forms; using System.Windows.Threading; public partial class W ...
- wpf 状态栏图标背景闪烁提醒 FlashWindowEx
原文:wpf 状态栏图标背景闪烁提醒 FlashWindowEx using System; using System.Runtime.InteropServices; using System.Wi ...
- WPF——TaskBarIconOverlay(任务栏图标叠加)
原文:WPF--TaskBarIconOverlay(任务栏图标叠加) <Window.Resources> <DrawingImage x:Key="OverlayIma ...
- C#:实现托盘(任务栏图标与托盘图标互斥)
实现托盘(任务栏图标与托盘图标互斥),并且在点击任务栏图标时实现的最小化与点击最小化按钮分离. 具体如下: 1.向窗体上添加如下控件:MenuStrip menuStrip1, NotifyIcon ...
- WPF 任务栏颜色 - 简书
原文:WPF 任务栏颜色 - 简书 先看看效果,这种效果可以用来做进度条或者消息通知闪烁. image.png image.png image.png image.png 有一个好消息 ...
- C# 程序启动最小化至任务栏及闪烁
主要功能: C#让窗体最小化至任务栏,同时在系统托盘区的图标点击左键能显示窗体,并使窗体闪烁. 首先: 创建窗体应用程序,并添加控件NotifyIcon及ContextMenuStrip控件 Noti ...
- WPF 4 动态覆盖图标(Dynamic Overlay Icon)
原文:WPF 4 动态覆盖图标(Dynamic Overlay Icon) 在<WPF 4 开发Windows 7 任务栏>一文中我们学习了任务栏的相关开发内容,同时也对覆盖图标 ...
随机推荐
- ZooKeeper学习第二期--ZooKeeper安装配置
一.Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式. ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境:■ 伪集群模式:就是在一台物 ...
- LINUX第五次实验报告
北京电子科技学院(BESTI) 实 验 报 告 课程:信息安全系统设计基础 班级: 201353 姓名:刘世鹏 郝爽 学号:2013530 ...
- 学习笔记——Maven超级POM
2014-07-04:更新如何在安装程序中找到超级pom文件.Maven有一个超级POM,所有的POM均继承此文件.你可以使用解压工具打开jar文件$M2_HOME/lib/maven-model-b ...
- TCP的三次握手和四次挥手
置顶文章:<纯CSS打造银色MacBook Air(完整版)> 上一篇:<两个简单的Loading> 作者主页:myvin 博主QQ:851399101(点击QQ和博主发起临时 ...
- FTP+SFTP工具类封装-springmore让开发更简单
github地址:https://github.com/tangyanbo/springmore FTPUtil 该工具基于org.apache.commons.net.ftp.FTPClient进行 ...
- 第二十七课:滚轮事件,mouseenter与mouseleave事件的修复
滚轮事件 jQuery核心库没有对mousewheel事件的差异性进行处理,但作为一个常用的事件,本文讲解一下. mousewheel事件只有火狐浏览器不支持.mousewheel用于取得滚动距离的属 ...
- dell r710 服务器配置RAID5(3块硬盘做RAID5,另外再弄一块做数据冗余盘)
本文完全转载于:http://www.jb51.net/article/53814.htm,只为做笔记使用 ①4块硬盘做成RAID5 ②3块硬盘做RAID5,一块硬盘做热备盘 这两种配置之间的区别.大 ...
- openvpn的介绍和搭建过程
本文摘自:http://www.linuxidc.com/Linux/2012-01/51702.htm,在这只是为了做个笔记使用
- OC基础--OC内存管理原则和简单实例
ARC: 由于自己的学习视频太早,Xcode是iOS6版本,新建命令行项目后,系统会默认启动ARC机制,全程Automatic Reference Counting,简单的说,就是代码中自动加入了re ...
- JQuery思维导图