我仍然困惑如何使它突出顯示任務欄項目,而不是閃光。這裏是最終爲我工作的代碼(我覺得將設置計數設置爲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