Reputation: 45
I am porting a Linux application to windows , there are two executable's which need to be launched on primary and secondary displays respectively.
In Linux its done through #!/bin/sh script,something like
display_start_dualhead LVDS 800 480 DVI 1024 768 24 export screen_main=$LVDS export screen_secondary=$DVI
how can this be done in Windows , launching exe1 in monitor 1 and exe 2 in monitor 2 ?
Upvotes: 1
Views: 76
Reputation: 36026
Process creation on windows is performed through the CreateProcess API which is passed a STARTUPINFO struct. This structure allows initial visibility and positional information to be passed to the launched process, with the intention that the process will use this when creating - and showing - its initial window.
I do not know of a built in command line tool that will populate the positional fields with the co-ordinates of each monitor, although the start
command can be instructed to launch the window maximised or minimized.
Nonetheless it should be a trivial exercise to make an application that enumerates the monitors and fills these fields in. That said - having done this you might just find that the applications ignore these fields and position their windows directly.
Upvotes: 1
Reputation: 133
Try this:
function void showOnMonitor1()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[0].Bounds.Width;
f.Top = sc[0].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[0].Bounds.Location;
Point p = new Point(sc[0].Bounds.Location.X, sc[0].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
}
function void showOnMonitor2()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[1].Bounds.Width;
f.Top = sc[1].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[1].Bounds.Location;
Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
}
OR
if (System.Windows.Forms.SystemInformation.MonitorCount != 1)
{
Form form2 = new Form();
form2.Left = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width + 1;
form2.Top = 0;
form2.ShowDialog();
}
Upvotes: 1