Moses Aprico
Moses Aprico

Reputation: 2121

How to make an application which has another screen in the extended screen?

I want to make an application which has another screen in the extended screen in another monitor (or in my case projector), similar to the presenter view in power point.

I want to use C#, and I guess in windows form application or wpf template there is no dual screen application support.

My first guess is to make 2 separate project and connect them, but I'm not sure about it either.

Any idea how to do it, or at least someone has a tutorial related to it?

I've looked at google, but still not sure what the right question to the issue, since google always showed "how to set up dual screen" for users.

Please clarify anything if my question is unclear. Thanks.

Upvotes: 0

Views: 2979

Answers (1)

Steven Mills
Steven Mills

Reputation: 2381

The easiest method I can think of is to simply create a second form (assuming you use Window Forms for your project), so you'd have Form1 as the default, and Form2 as your second form.

Run Form1 by default, and then while loading Form1, do something like this:

if(System.Windows.Forms.Screen.AllScreens.Length > 1)
{
   Form2 form2 = new Form2();
   form2.Show();
}

Then within form2's shown event, set it's position to the second screen (and perhaps maximize it, depending on what you need).

private void Form2_Shown(object sender, EventArgs e)
{
    this.Location = Screen.AllScreens[1].Bounds.Location;
    this.WindowState = FormWindowState.Maximized;
}

From that point on (and provided you keep a reference to Form2 within Form1), you can easily exchange information between the two forms as needed. You could even expand it to support 3-4 monitors, simply by making multiple Form2's, one for each screen

Upvotes: 1

Related Questions