原文:WPF 任务栏图标闪烁提醒

 
 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.Start(Window w);

停止:FlashWindow.Stop(Window w);

.NET技术交流群 199281001 .欢迎加入。

WPF 任务栏背景闪烁提醒的更多相关文章

  1. wpf 状态栏图标背景闪烁提醒 FlashWindowEx

    原文:wpf 状态栏图标背景闪烁提醒 FlashWindowEx using System; using System.Runtime.InteropServices; using System.Wi ...

  2. WPF 任务栏图标闪烁提醒

    using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServi ...

  3. WPF 任务栏颜色 - 简书

    原文:WPF 任务栏颜色 - 简书 先看看效果,这种效果可以用来做进度条或者消息通知闪烁.   image.png   image.png   image.png   image.png 有一个好消息 ...

  4. 解决Winform应用程序中窗体背景闪烁的问题

    本文转载:https://my.oschina.net/Tsybius2014/blog/659742 我的操作系统是Win7,使用的VS版本是VS2012,文中的代码都是C#代码. 这几天遇到一个问 ...

  5. 自定义iOS7导航栏背景,标题和返回按钮文字颜色

    在iOS7下,默认导航栏背景,颜色是这样的,接下来我们就进行自定义,如果你仅仅是更改一下背景和颜色,代码会很简单,不需要很复杂的自定义View来替代leftBarItem 更改导航栏的背景和文字Col ...

  6. IOS 实现自定义的导航栏背景以及自定义颜色的状态栏(支持7.0以及低版本)

    为尊重文章原作者,转载务必注明原文地址:http://www.cnblogs.com/wt616/p/3784717.html 先看效果图: 在自定义导航栏背景时,可能会遇到以下一些问题: 1.当设置 ...

  7. 【转】自定义iOS7导航栏背景,标题和返回按钮文字颜色 -- 不错不错!!

    原文网址:http://blog.csdn.net/mad1989/article/details/41516743 在iOS7下,默认导航栏背景,颜色是这样的,接下来我们就进行自定义,如果你仅仅是更 ...

  8. listview滚动时背景闪烁,背景黑或白问题解决

    android在使用listview时出现滚动时背景闪烁,变成背景黑或白的问题这样处理: 1:在布局文件中listview标签中加入: android:cacheColorHint="#00 ...

  9. 【转】 自定义iOS7导航栏背景,标题和返回按钮文字颜色

    原文:http://blog.csdn.net/mad1989/article/details/41516743 UIBarButtonItem,navigationItem,backBarButto ...

随机推荐

  1. Java强引用、软引用、弱引用及虚引用深入探讨

    强引用.软引用.弱引用和虚引用深入探讨 为了更灵活的控制对象的生命周期,在JDK1.2之后,引用被划分为强引用.软引用.弱引用.虚引用四种类型,每种类型有不同的生命周期,它们不同的地方就在于垃圾回收器 ...

  2. JS笔记(二):对象

    (一) 对象 对象是JS的基本数据类型,类似于python的字典.然而对象不仅仅是键值对的映射,除了可以保持自有的属性,JS对象还可以从一个称为原型的对象继承属性,对象的方法通常是继承的属性.(这种对 ...

  3. Python CNN卷积神经网络代码实现

    # -*- coding: utf-8 -*- """ Created on Wed Nov 21 17:32:28 2018 @author: zhen "& ...

  4. Python实现批量梯度下降算法

    # -*- coding: UTF-8 -*- import numpy as npimport math # 定义基础变量learning_rate = 0.1n_iterations = 1000 ...

  5. 使用wxpy自动发送微信消息

    思路整理:1.进入心灵鸡汤网页,使用python获取心灵鸡汤内容 2.登陆微信,找到需要发送的朋友 3.发送获取的内容 1.获取心灵鸡汤的内容 如下图,获取第一条鸡汤 实现如下: 2.登陆微信,搜索朋 ...

  6. Chrome及Chrome内核浏览器改变开发者工具字体大小

    1.打开浏览器,按F12调用开发者工具 2.按Ctrl+数字加号键,可看到字体变大,按Ctrl+数字减号键,字体变小 3.重新启动浏览器后字体仍然保持修改后的字体大小

  7. 第一次安装tomcat报错,出现failed to install tomcat8 service错误

    第一次安装tomcat报错,出现failed to install tomcat8 service错误(0) 一.一般情况下这种错误都是没有卸载干净造成的,安全卸载Tomcat的方法 (转载); ht ...

  8. 寒假集训——搜索 B - Sudoku

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream&g ...

  9. Spring配置文件中的那些标签意味着什么(持续更新)

    前言 在看这边博客时,如果遇到有什么不清楚的地方,可以参考我另外一边博文.Spring标签的探索,根据这边文章自己来深入源码一探究竟.这里自己只是简单记录一下各标签作用,每个人困惑不同,自然需求也不一 ...

  10. jQuery:自定义函数

    <!doctype html><html><head><meta charset="utf-8"><title>< ...