在几乎所有信使中,当您的IM窗口最小化到任务栏时,IM任务栏项目会在您有新消息时更改颜色或变亮。我一直在寻找有关如何使用.NET Winforms或WPF
执行此操作的任何帮助任何代码示例?
=============================================== ======================
编辑:我在我的WPF窗口中使用了FlashWindow。
参考:http://www.aeoth.net/blog/2007/04/27/flashing-the-window-in-wpf-c-2/
答案 0 :(得分:7)
您需要使用FlashWindowEx功能。基本上,获取窗口的句柄,使用句柄创建FLASHWINFO结构以及窗口如何闪烁(连续,直到打开等),并将其传递给FlashWindowEx。
编辑:这是如何在C#中执行的example。
答案 1 :(得分:0)
我仍然感到困惑如何使它只是突出显示任务栏项而不是闪烁。这里的代码最终为我工作(我觉得将设置数设置为1非常愚蠢,希望这会节省别人的时间)。
Public Structure FLASHWINFO
Public cbSize As UInt32
Public hwnd As IntPtr
Public dwFlags As UInt32
Public uCount As UInt32
Public dwTimeout As UInt32
End Structure
Private Declare Function FlashWindowEx Lib "user32.dll" (ByRef pfwi As FLASHWINFO) As Boolean
Private Const FLASHW_STOP As UInt32 = 0
Private Const FLASHW_CAPTION As UInt32 = 1
Private Const FLASHW_TRAY As UInt32 = 2
Private Const FLASHW_ALL As UInt32 = 3
Private Const FLASHW_TIMER As UInt32 = 4
Private Const FLASHW_TIMERNOFG As UInt32 = 12
Public Shared Sub Flash(ByRef thisForm As Form)
Dim flash As New FLASHWINFO With {
.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(flash),
.hwnd = thisForm.Handle,
.dwFlags = FLASHW_TRAY Or FLASHW_TIMERNOFG,
.uCount = 1}
'Leaving out .dwCount seems to work just fine for me, the uCount above keeps it from flashing
FlashWindowEx(flash)
End Sub