I have an Winform application that receives a command line parameter that specify if it would be displayed on the main Monitor of the second Monitor via a I-Omega USB Dual Monitor connector.
The application runs on a laptop and uses two monitor.
1. The first monitor just connect to the laptop VGA port. I run the “MyApplication.exe 1”
2. The second monitor is connected via USB dual monitor VGA port. I run the second instance “MyApplication.exe 2”
I was able to force the second instance of the application to go to the second montior by using Screen.AllScreens and changing the Form’s location. I specified in the Power Setting of the laptop not to go on Standby or turnoff monitor if laptop is folded. When I close the laptop monitor, both instance of the application remains on their respective monitor. But when I reopen the laptop, the second instance moves the the first screen.
My question is there a monitor open event in .NET? Or are there other settings to retain the second instance to the second monitor/Screen?
I know there is a WM_POWERBROADCAST event but, I already set the laptop not to sleep.
I was able to do this not by windows event but by using a timer. Basically the timer would check for the location of the Window with the desired screen. If it does not match the desired screen, I would adjust the location again to move to the desired monitor. I added tolerance of 4(WinXP)~8(Win7)pixels when checking if the top-left location is equal. The top and left location becomes (-4,-4) when in maximized state. When in minimized state, I dont check the location.
I used the ShowOnMonitor method from a previous question:
How do I ensure a form displays on the "additional" monitor in a dual monitor scenario?