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 任务栏>一文中我们学习了任务栏的相关开发内容,同时也对覆盖图标 ...
随机推荐
- python实现概率分布
1. 二项分布(离散) import numpy as np from scipy import stats import matplotlib.pyplot as plt ''' # 二项分布 (b ...
- JS insertAdajcentHTML 方法简介
修改节点的内容除了常用的innerHTML和innerText之外,还有insertAdjacentHTML和insertAdjacentText方法,可以在指定的地方插入内容.insertAdjac ...
- Spring MVC实现文件下载
下载文件① 下载文件需要将byte数组还原成文件. 首先使用mybatis将数据库中的byte数组查出来,指定文件名(包括格式).然后使用OutputStream将文件输入 @RequestMapp ...
- 《深入理解计算机系统》深入实践之——vim深入研究
vim 用户手册中,大部分的例子都是在讲 vim 如何高效编写代码,由此可见,vim 是一款面向于程序员的多功能编辑器,即使某些功能 vim 无法直接完成,借助其丰富的插件资源,必定可以达成目标,这就 ...
- 20135316王剑桥 linux第五周课实验笔记
4.1.1程序员的可见的状态 ———— Y86的每条指令都会读取或修改处理器状态的某些部分,称为程序员可见状态.如图1所示. 1.程序寄存器(Program registers): %eax, %ec ...
- 《信息安全系统设计基础》实验五 简单嵌入式WEB服务器实验
实验报告链接:http://www.cnblogs.com/lx20145332/p/6058790.html
- bt协议详解 DHT篇(下)
bt协议详解 DHT篇(下) 最近开发了一个免费教程的网站,产生了仔细了解bt协议的想法,这篇文章是bt协议详解系列的第三篇,后续还会写一些关于搜索和索引的东西,都是在开发这个网站的过程中学习到的技术 ...
- 【Win 10应用开发】如何知道当前APP在哪个平台设备上运行
在做Win10开发的时候,我们可能经常会需要获得当前程序在在哪个平台设备上运行,用于UI和相关API的调用,那么可以通过什么方式知道当前APP运行的平台呢? 今天这里提供两个方法给大家做参考: 方法一 ...
- 大数据:从开源告诉你身边的IT故事
最近我们Team利用Dream分布式计算平台,做了这样一件事情,将Github的大量数据通过爬虫抓取下来,通过分析后,我们抽取最近一年中部分的开发者和项目信息,得到了如下有趣的信息,故分享之,数据原汁 ...
- Cordova4.0 系列 -- 基本环境搭建(1)
一. 安装Node.js基本环境 官网下载地址:https://nodejs.org/ 安装成功之后可以使用简单命令查看其版本 node -v npm相关命令 node cli.js install ...