Same application in dual monitor

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Actually the thing is i am devoloping a windows application, which will be
displayed in multiple monitors.

i have one single exe, which will be displayed in 2 monitors for example. In
cloning mode (windows display setting) both the screen will display the same
content. (eg. form1 will be displayed in screen1 and screen 2, since both
are same, check box click on screen 1 will show check box click on screen2).

Now in my case i want to show 2 different forms of same exe in screen1 and
screen 2. (eg. form1 in screen1 and form4 in screen2).

(1) first how do i do that? or is there any alternative ways?

(2) If i click a check box on form1(screen1), although the screen2 display
form4 , the check box on form1 in screen 2 should be checked.

how do i achieve this functionality.

There are actually 2 touch panels connected to the system. And both the
touch panels are interactive and shows the same(one main part of the
application). In the application for example there are 2 forms in which
through one form it controls temperature of the room and through other form
it controls room light.

But since this is one exe at a time only one operation will happen.(for eg.
if an operation in form1 hangs the system(screen1), system will be hanged in
screen2 too even it doent show form1)

In extended display, can we show same application, interactive in both the
screens? in which the screen can show same form or different form?

right now i am thinking to create 2 objects on form1 at runtime and attach
to the screen boundaries. but how we communicate an event in one object to
another object?
 
Actually the thing is i am devoloping a windows application, which will be
displayed in multiple monitors.

i have one single exe, which will be displayed in 2 monitors for example. In
cloning mode (windows display setting) both the screen will display the same
content. (eg. form1 will be displayed in screen1 and screen 2, since both
are same, check box click on screen 1 will show check box click on screen2).

Now in my case i want to show 2 different forms of same exe in screen1 and
screen 2. (eg. form1 in screen1 and form4 in screen2).

(1) first how do i do that? or is there any alternative ways?

(2) If i click a check box on form1(screen1), although the screen2 display
form4 , the check box on form1 in screen 2 should be checked.

how do i achieve this functionality.

There are actually 2 touch panels connected to the system. And both the
touch panels are interactive and shows the same(one main part of the
application). In the application for example there are 2 forms in which
through one form it controls temperature of the room and through other form
it controls room light.
But since this is one exe at a time only one operation will happen.(for eg.
if an operation in form1 hangs the system(screen1), system will be hanged in
screen2 too even it doent show form1)
In extended display, can we show same application, interactive in both the
screens? in which the screen can show same form or different form?
right now i am thinking to create 2 objects on form1 at runtime and attach
to the screen boundaries. but how we communicate an event in one object to
another object?

Hi Amb,

This is possible using DataBinding. If you are familiar with DataBinding simply have a common object holding all the values displayed in the screen and bind all the controls to their own properties on this object. Updating the underlying property will cause an update to all the controls bound to this property (you may need the holding class implement INotifyPropertyChanged and have the properties trigger the NotifyChanged event)
 
Hi Morten,
Can you please elaborate on this. Actually i do not have any idea regarding
databinding and it's implementation. Also can you please share some articles
related to this. Thanks
 
Hi Morten,
Can you please elaborate on this. Actually i do not have any idea regarding
databinding and it's implementation. Also can you please share some articles
related to this. Thanks

What DataBinding does is bind a property on a Control to a property on an object. Whenever you change the value of the control, the value of the property on the object will automatically change as well. Likewise can you programmatically change the value of the property on the object and have it "magically" displayed.

The code below has a MainForm the launches two Form1 on two different screens. MainForm also passes a MyObject object to the constructor of Form1. MyObject will hold the data value of the checkbox (true or false) so MyObject has a property for this, called Checked (the name of the property can be anything, but the data type must be identical to the property of the control).

Form1 specifies that checkBox1 should have a DataBinding and adds a new Binding object that mirrors the Checked property of the CheckBox to the Checked property of MyObject. DataSourceUpdateMode.OnPropertyChanged tells the DataBinding to update the underlying object immediatly if the control value changes. For TextBoxes this means, whenever a character is entered, as opposed to DataSourceUpdateMode.OnValidation, which will change the underlying object once you leave the control. DataSourceUpdateMode.Never does just that, any changes in the control will not be sent tothe object.

I have added code on MyObject that will call any controls bound to a specific property when the property is changed. Although the code will work without calling notifyPropertyChanged, if you change the Checked property programmatically you will have to use it to have the display update itself.

Search for 'C# DataBinding Tutorial' on the web to get you started.

In addition to the code below you need to add a CheckBox called checkBox1 to Form1. MainForm and Form1 are Windows forms and MyObject is a class.

PS! MainForm is set to auto hide and will open if you click on the tray icon called "ScreenTest"

// MainForm
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ScreenTest
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();

TopMost = true;

NotifyIcon icon = new NotifyIcon();
icon.Icon = this.Icon;
icon.Text = "ScreenTest";
icon.Visible = true;
icon.MouseDown += new MouseEventHandler(icon_MouseDown);
}

void icon_MouseDown(object sender, MouseEventArgs e)
{
if (WindowState != FormWindowState.Minimized)
{
WindowState = FormWindowState.Minimized;
Hide();
}
else
{
WindowState = FormWindowState.Normal;
Show();
}
}

private void MainForm_Load(object sender, EventArgs e)
{
MyObject myObj = new MyObject();
new Form1(myObj, Screen.AllScreens[0].Bounds).Show();
new Form1(myObj, Screen.AllScreens[1].Bounds).Show();
WindowState = FormWindowState.Minimized;
Hide();
}

protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
if (WindowState == FormWindowState.Minimized)
ShowInTaskbar = false;
else
ShowInTaskbar = true;
}

}
}

//Form1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ScreenTest
{
public partial class Form1 : Form
{
MyObject myObj = null;
public Form1(MyObject myObj, Rectangle bounds)
{
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
this.myObj = myObj;
this.Bounds = bounds;
}

protected override void OnLoad(EventArgs e)
{
checkBox1.DataBindings.Add("Checked", myObj, "Checked", false, DataSourceUpdateMode.OnPropertyChanged);
}
}
}

//MyObject
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ScreenTest
{
public partial class Form1 : Form
{
MyObject myObj = null;
public Form1(MyObject myObj, Rectangle bounds)
{
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
this.myObj = myObj;
this.Bounds = bounds;
}

protected override void OnLoad(EventArgs e)
{
checkBox1.DataBindings.Add("Checked", myObj, "Checked", false, DataSourceUpdateMode.OnPropertyChanged);
}
}
}
 
Hi Morten,
Thank you very much for making me understand the concept. I have checked the
code successfully. I am now trying to implement INotifyPropertyChanged
interface,hope that will also works.
 
Hi morten
I want to know one more thing. I have defined a picturebox control defined
in the common class and i am loading the picturebox to a panel defined in
form1. Now when i load two form1 screens at the same time only the last
displayed form shows picturebox. How can i show the same picturebox on both
the screens of form1. Any idea?
 
Back
Top