原文: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. Salesforce的基础用户界面定制

    Salesforce的用户界面 Salesforce的用户界面易于定制.本文将讲述如何定制: 主菜单和选项卡 自定义按钮和链接 视图列表 页面布局 定制主菜单和选项卡 Salesforce的主菜单默认 ...

  2. JMeter 利用Jmeter批量数据库插入数据

    利用Jmeter批量数据库插入数据   by:授客 QQ:1033553122 1.   启动Jmeter 2.   添加 DBC Connection Configuration 右键线程组-> ...

  3. React 表单与事件

    一个简单是实例 在实例中我们设置了输入框 input 值value = {this.state.data}.在输入框值发生变化时我们可以更新 state.我们可以使用 onChange 事件来监听 i ...

  4. Scoop Windows 的命令行安装程序管理工具

    传送门: # 官网 http://scoop.sh/ # github https://github.com/lukesampson/scoop window中快速安装: 必须使用powershell ...

  5. MySQL 复制夯住一例排查以及原理探讨

    目录 目录 一 引子 二 故障分析 三 故障解决 四 原理探讨 五 小结 文/温国兵 一 引子 研发反应,有台从库和主库不同步.由于业务读操作是针对从库的,数据不同步必定会带来数据的不一致,业务获取的 ...

  6. tkinter学习系列之(七)Frame与Labelframe 控件

    目录 目录 前言 (一)Frame (二)Labelframe 目录 前言 Frame与Labelframe都是容器,用来存放其他控件,也是用来更好的管理布局. 我一般是用来存放一组相关的控件,让Fr ...

  7. 4.4Python数据类型(4)之字符串函数

    返回总目录 目录: 1.字符串的查找计算 2.字符串的转换 3.字符串的填充压缩 4.字符串的分割拼接 5.字符串的判定 (一)字符串的查找计算 (1)len(str)计算字符串的总数 (2)find ...

  8. Http协议响应状态类别及说明

    HTTP响应由三个部分组成,分别是:状态行.消息报头.响应正文  状态行格式如下: HTTP-VersionStatus-Code Reason-Phrase CRLF 其中,HTTP-Version ...

  9. IO流_文件切割与合并

    切割可以分两种方式:按文件个数切,按文件大小来切(建议用这种方式,因为按个数的话,有可能文件非常大) import java.io.File; import java.io.FileInputStre ...

  10. 寒假集训——搜索 D - Cubes for Masha

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