|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace MultiScreenPOC
{
public partial class frmMain : Form
{
Form[] aryForms = new Form[5]; // Allow 5 total forms.
int currentPointer = 0; //
Screen[] scr = Screen.AllScreens;
public frmMain()
{
InitializeComponent();
LoadScreen();
}
private void LoadScreen()
{
String strDeviceName = String.Empty;
this.cmbDevices.Items.Clear();
foreach (Screen s in scr)
{
strDeviceName = s.DeviceName.Replace("\\\\.\\", "");
this.cmbDevices.Items.Add(strDeviceName);
/** you can check the device is primary or not this way
if (s.Primary)
{
this.cmbDevices.Items.Add(">" + strDeviceName);
}
else
{
this.cmbDevices.Items.Add(strDeviceName);
}
*/
}
this.cmbDevices.SelectedIndex = 0;
}
private void btnLaunchIn_Click(object sender, EventArgs e)
{
int intLaunchScreen = getScreenNumber(this.cmbDevices.SelectedItem.ToString());
if (currentPointer <= 4)
{
aryForms[currentPointer] = new frmLaunchedWindow();
aryForms[currentPointer].Text = aryForms[currentPointer].Text + currentPointer;
aryForms[currentPointer].Left = scr[intLaunchScreen].Bounds.Width;
aryForms[currentPointer].Top = scr[intLaunchScreen].Bounds.Height;
aryForms[currentPointer].StartPosition = FormStartPosition.Manual;
aryForms[currentPointer].Location = scr[intLaunchScreen].Bounds.Location;
//Point p = new Point(scr[0].Bounds.Location.X, scr[0].Bounds.Location.Y);
//aryForms[currentPointer].Location = p;
aryForms[currentPointer].Show();
currentPointer += 1;
}
}
private int getScreenNumber(String DeviceID)
{
int i = 0;
foreach (Screen s in scr)
{
if (s.DeviceName == "\\\\.\\"+DeviceID)
{
return i;
}
i += 1;
}
// if cannot find the device reset to the default 0
return 0;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Resident of Hong Kong, TOGAF 8 certified architect with over 15 years of international experience in the IT industry. Exceptional exposure to the marine / shipping technologies and knowledge of large scale database system architecture, enterprise systems design and work flow implementation.