# FlashWindow Function

`Declare Function FlashWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal bInvert As Long) As Long`

FlashWindow flashes a window one step. Flashing is where the title bar of the window is switched from an active to inactive look (or vice versa) to get the user's attention. Normally this is done multiple times, instead of just once. When you are done flashing, be sure to call the function again, this time with bInvert set to 0. The function returns 0 if the window's look was inactive before flashing, or a non-zero value if its look was active.

hwnd
  The handle of the window to flash one step.
bInvert
  Specifies how to flash. If non-zero, switches the title bar from an active to inactive look (or vice versa). If zero, restores the window to its normal look.

Example:

    ' Flash Form1 five times to get the user's attention
    For c = 1 To 10  ' flash on five times, off five times
      x = FlashWindow(Form1.hWnd, 1)  ' flash another step
      Sleep 500  ' API halts program for 500 milliseconds (1/2 second)
    Next c
    x = FlashWindow(Form1.hWnd, 0)  ' restore normal look to window

Category: Windows
Back to the index.