I am making an add on for a game, but I want it to reside as an overlay to the game's client area of the window.
Basically when I start the add on, i want it to show on top of the game. The catch is if you minimize or move the window, I want the the form to stick with it.
Anyone know of anything that can do the trick without having to hook directdraw?
Thanks.
Here is a simple way to do this. First, you'll need this line in your form's using statements:
Next, add these declarations to your form:
Next, set your form's TopMost property to True. Finally, add a Timer control to your form, set its Interval property to 250 and its Enabled property to True, and put this code in its Tick event:
This code will keep your form positioned over the game's form if the game is not minimized, or it will minimize your form also if the game is minimized. To change the relative position of your application, just change the "+ 10" values in the last line.
The more complicated method would involve hooking windows messages to determine when the game form minimizes or moves or changes size, but this polling method will accomplish almost the same thing much more simply.
One last bit: FindWindow will return 0 if it finds no window with that title, so you could use this to close your own application when the game is closed.