Yesterday I dropped some code on my site that used the FlashWindow function. I mentioned that I had trouble getting the FlashWindowEx function working. Bill suggested that I might have picked up a bug copyinig the code from the pinvoke.net site. Bill was right, that was one of the problems and I have fixed up the page in question (gotta love Wiki’s).

The other problem that I was having was that in my test harness I was kicking the flash effect with a button but setting the behaviour flags with FLASHW_ALL | FLASHW_TIMERNOFG, the later value means that it flashes until the window becomes the foreground window, since it was, it stopped before I saw anything – duh!

Anyway, I’ve updated the code. Because I am now using FlashWindowEx I added a few extra features that the previous component didn’t have. First up – you can specify the interval between the flashing to make it go faster and be more noticable. You do this by setting the FlashInterval property.

Secondly you can specify that it flash for a specified period of time (TotalDuration) or a certain number of times (FlashCount). FlashCount and TotalDuration cannot be non-zero at the same time. I also added some logic to disallow setting negative values on all three properties – FlashCount, TotalDuration and FlashInterval. Enjoy (and thanks Bill)!