views:

723

answers:

5

In Windows XP, when a program wants the user's attention, it'll flash its taskbar button orange. Anyone with an IM program is probably familiar with this behavior. But when I'm playing a fullscreen-mode game, I don't see that, and messages go unanswered.

Now I'm writing a game engine of my own, and I'd like to be kind to my users. Is there any Windows API call I can write a hook for that will notify my program whenever any other program just set its taskbar button to "orange flashing mode"? That way, I could notify the user when it happens.

I'd be surprised if this isn't available. I saw a Mac OS Classic screensaver that was able to do this way back in the mid-90s. That's where I got the idea from.

EDIT: This got flagged as a duplicate of how-can-i-programmatically-determine-if-an-application-is-flashing-in-the-taskb but I reopened it because the answers are better on this one, and to encourage more people to discuss possible solutions, if any exist.

A: 

It looks like this question has been asked before on SO: How can I programmatically determine if an application is flashing in the taskbar

Short answer: doesn't appear to be possible.

William Brendel
+2  A: 

I don't think there is such a thing. You might be able to achieve it with API hooking, although I'm not sure Vista will allow you to do that. Works on XP though.

There are however a few other ideas in this direction that might be "the next best thing":

  • Don't take exclusive ownership of sound devices, so that sounds from other programs can be heard. I'm not sure how this is done, but some games block other sounds, some don't;
  • Allow user to switch away from your game with ALT-TAB and other key combinations;
  • If another window tries to become active, allow it to and gracefully minimize;

Other general tips include:

  • Try to keep minimize/restore times down. I don't know anything about game programming, but for some games this takes ages.
  • Properly restore picture when minimizing/restoring. Some games have issues with this.
  • Auto-pause on minimize. If it's a network game and not possible to pause, perhaps send a message to other players so they know.
  • Somewhat unrelated, but I love it when games show the clock somewhere (real clock, not some game time). This way I can easily tell if I should go to bed already without minimizing the program. :)
Vilx-
All very good ideas. Personally, programs that disable ALT-TAB, ALT-F4, or other basic functionality drive me up the wall. If the user tries to do something and the application programmer says "I'm sorry Dave...", how is that any better than writing malware?
Mason Wheeler
A: 

Of course it's possible. It's even a Win32 FAQ (for years...) see Adv. api ng news://comp.os.ms-windows.programmer.win32

Well, I found the newsgroup, but I can't find the question or the answer to it. Link please?
Mason Wheeler
A: 

Here are few links to get you started on Api hooking

www.internals.com/articles/apispy/apispy.htm www.wheaty.net/

Vista in general has no issue with API hooking other than the fact that it does not allow you to hook protected processes.

AppDeveloper
A: 

It is fully possible to do. I'm doing it on Windows 7 so I'm pretty sure it's possible to do on Vista as well.

UnKnownUser