How do I stop FlashWindowEx when me.handle gets focus?

  • Thread starter Thread starter Marc Miller
  • Start date Start date
M

Marc Miller

Hi....

I'm using FlashWindowEx to flash the taskbar and titlebar when my processes
are done.
I set the number of flashes to 5. But when the user returns to the window
the flashing
continues until all 5 flashes complete.

How do you stop the flashing once the user returns to the app.? (Code
Below)

Thanks for any help,
Marc Miller

Public Structure FLASHWINFO
Public cbSize As Int32
Public hwnd As IntPtr
Public dwFlags As Int32
Public uCount As Int32
Public dwTimeout As Int32
End Structure

Private Declare Function FlashWindowEx Lib "user32.dll" (ByRef pfwi As
FLASHWINFO) As Int32

Private Const FLASHW_CAPTION As Int32 = &H1
Private Const FLASHW_TRAY As Int32 = &H2
Private Const FLASHW_ALL As Int32 = (FLASHW_CAPTION Or FLASHW_TRAY)


Public Sub FlashNow(ByVal sender As System.Object, ByVal e As
System.EventArgs, ByVal iTimes As Integer)

Dim flash As New FLASHWINFO
flash.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(flash)
'/// size of structure in bytes
flash.hwnd = Me.Handle '/// Handle to the window to be flashed
flash.dwFlags = FLASHW_ALL '/// to flash both the caption bar + the
tray
flash.uCount = iTimes '/// the number of flashes
flash.dwTimeout = 1000 '/// speed of flashes in MilliSeconds ( can
be left out )
'/// flash the window you have specified the handle for...
FlashWindowEx(flash)

End Sub
 
Call FlashWindowEx again using FLASHW_STOP as the value for dwFlags.

Here is a declaration for FLASHW_STOP:

Private Const FLASHW_STOP As Int32 = &H0
 
Back
Top