Mason Wheeler
Mason Wheeler

Reputation: 84650

Is there a Windows API hook for "this application wants attention"?

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.

Upvotes: 3

Views: 1357

Answers (1)

Vilx-
Vilx-

Reputation: 107042

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. :)

Upvotes: 3

Related Questions