views:

173

answers:

2

Hello,

how could I send an application (think WM_ messages?) which is not my application (think: any 3rd party app) to a different screen on a multiscreen system? Is there a specific windows message code I can send to the window or process handle to do this?

+1  A: 

I've never tried this, but how about using WM_MOVE? The SendMessage function will allow you to send the required message. Since you've marked your question as using C#, you'll have to use p/invoke to use it. Here's an example.

As for getting screen locations and sizes, see the Screen class in the .Net library. There's one function called FromHandle(), and a property called AllScreens which returns an array of all the valid screens the user has. FromHandle() will tell you which screen the app is currently occupying the most (this may or may not be useful in your case). This will allow you to compute the desired location of the 3rd party application, before sending the message to that application.

Charlie Salts
+1  A: 

You'll want to use P/Invoke and the MoveWindow function.

Edit: It handles multiple screens just fine. MoveWindow sees your screens as one big display, and takes arguments accordingly. You can use the .Net Screen class to find the bounds of the screen you want, and then call MoveWindow to get the window where you want it.

Also, in case you weren't aware of it, there's a good chance that your project is probably going to need the FindWindowByCaption function as well.

Iceman
I did not know about this one - does it handle multiple screens?
Charlie Salts