Reputation: 116
i have a C# application that should open a process on the second screen if there are more than one screen. I just cannot get it working. Any ideas?
Array screens = Screen.AllScreens;
if (screens.Length > 1)
{
// open in the second monitor
}
else
{
System.Diagnostics.Process.Start(InputData);
}
It should be the same data as in else
, but just open this on the second monitor in the now empty if
.
Upvotes: 0
Views: 1529
Reputation: 13794
you can achieve this by changing your MainForm of the input process like the following
public Form1()
{
this.StartPosition =FormStartPosition.Manual;
InitializeComponent();
Screen sndSc = Screen.AllScreens[1];
if (sndSc.Primary)
{
sndSc = Screen.AllScreens[0];
}
this.Height = sndSc.WorkingArea.Height;
this.Width = sndSc.WorkingArea.Width;
this.Location = sndSc.WorkingArea.Location;
}
Upvotes: 2
Reputation: 292705
There is no standard way to specify on which screen the application will appear when you launch it. However, you could either:
Upvotes: 3
Reputation: 9800
You should do the same thing you do when you position your window.
To display a window on any monitor, you should reposition it according to that monitor's coordinates.
Lets say you have two monitors, both of 1920x1080 resultion and they are arranged side by side. In this situation, to show a form on the second screen, you must set form's X coordinate (or Left
property, my guess) more than 1920.
Upvotes: 1