How to open a WPF Application in a specific Place on a Specific Monitor

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 09:37:53

问题


I have two application which communicates together, to be more specific I have app1.exe and app2.exe this 2 apps are in the same PC which has one monitor and one TV how can I open app1.exe on TV and the other on my Monitor. Actually to do this I'm using a third party tool which is named Actual Multiple Monitors. my goal is to remove this tool because I'm using this only for the function to open my applications in the right place. it would be great if there is a possibility to do this using code. I'm using WPF in Visual Studio 2010?


回答1:


The following assumes that you have the source code to your applications:

You need to do a couple of things:

Firstly use System.Windows.Forms.Screen() to enumerate your screens.

Screen[] allScreens = Screen.AllScreens;

Then you can you use the Screen.Bounds property to determine where to display your main window.

I don't know how you change the location of your main window in WPF - in Windows Forms you just override OnLoad() and set the Form.Location and Form.Size appropriately. I imagine WPF has something similar.




回答2:


In case Matthew Watson's answer doesn't work, your window may be in Maxmized state. In this case, set its state to WindowState.Normal, change top/left and revert the WindowState.



来源:https://stackoverflow.com/questions/13742259/how-to-open-a-wpf-application-in-a-specific-place-on-a-specific-monitor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!