You will have noticed that sometimes, applications flash their title bars to get your attention! Well, you can do this with your program, using the FlashWindow API call. First of all, declare the API call:
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Then, you call it like this:
FlashWindow hWnd, 0
where hWnd is the hWnd property of the window you want to flash. You will notice, however, that this doesn't seem to do anything. This is because when you call the function like this, it simply activates the title bar - and if the title bar is already activated, nothing will happen. If you pass 1 as the second parameter, the title bar will flash:
FlashWindow hWnd, 1
If you want the title bar to flash more than once, the simplest way to do this is to use a timer. You could use something like the code below:
Private Sub tmrFlash_Timer()
FlashWindow hWnd, 1
End Sub
For this to work, you need a Timer control on the form, called tmrFlash. When you want the title bar to start flashing, set tmrFlash.Enabled = True. When you want it to stop, set tmrFlash.Enabled = False. You will also need to decide on the Interval (by setting the Interval property of the Timer) between the flash. I find 500 works quite well.
Comments