我仍然困惑如何使它突出显示任务栏项目,而不是闪光。这里是最终为我工作的代码(我觉得将设置计数设置为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
在C#中的另一个例子在这里:http://jarloo.com/code/wpf/flashing-a-wpf-window/ – manuc66 2011-08-11 11:28:01
上面的链接现在已经过时了,新的链接= http://www.jarloo.com/flashing-a-wpf-window/ – RenniePet 2011-10-11 02:40:09