views:

373

answers:

1

Hello. Does anyone know how I can create a screen overlay while a program is running? Mainly while a game is running. If anyone has used xFire or Steam, these use this feature.

I've created a winform which starts the game/program and then minimizes. Could the overlay be created in the same winform? Thanks for the help! :)

+1  A: 

I'm assuming you mean an overlay.

No, there's no way to create one for most games using Windows Forms. You'll need to attach to the DX surface manually. The best way of doing this is to use native C/C++; it's theoretically possible to do this using C# but it would be extraordinarily slow and kludgy.

Dan Story
Yeh, sorry. I meant a overlay, not an overflow. So could I get a C++ program to run when the C# program runs the game? process.start maybe? Any idea how I would get the C++ program to overlay the game? When a certain key is pressed maybe? That would mean that the C++ program will need to be running all the time though.
Joey Morani
Typically the overlay process starts before the game and waits for the DX surface to be created in the game process, then hooks in. You can have the overlay auto-shutdown when the game destroys the DX surface if you don't want it hanging around waiting for it to start up again.
Dan Story
Well, you are partially wrong - you can attarch managed code to unmananged one and it isn't THAT bad.
Migol
You can attach managed code for control process to unmanaged, sure, but if you try to use managed code for all of the graphics code (using PInvoke to talk to DX) it will be unworkable due to the context-switch/marshalling overhead on all but the most powerful computers. You could certainly use SlimDX to bridge the gap, but that's a C++/CLI library and so you're not really doing it in C# anymore.
Dan Story
@Dan Story, just a minor correction, SlimDX isn't C++/CLI as it is available for the Xbox 360.
Matt Olenik