views:

199

answers:

0

For my window sitter project (remember that one question about colorkeying?) I'm currently using a Timer to update the character's position, like I did with the original VB6 version. There are, however, a few problems with this approach:

If you switch windows or move the foreground window fast enough, the character lags unless you set the timer to a very small interval. This would mean that it would determine the foreground window and final sitting position every fraction of a second, with all the processor hogging that involves. Incidentally, this is not a whole lot on today's systems. BUT! The second problem was shown to me when I ran the program through FxCop: less than a second intervals apparently break the system's power management.

My first idea is to switch having the program poll for changes to letting the system notify the program. But how should this be tackled? And somewhat importantly, can the code stay relatively readable by a bunch of newbs once they get a copy so they can make their own window sitters from it?

Update: I found out that another Window Sitter (which was Win32 C++) used hooks to detect foreground window changes.