?
Solved

Windows Forms: Full Screen on secondary display problem

Posted on 2009-04-09
2
Medium Priority
?
2,432 Views
Last Modified: 2013-11-07
Hi,

I've got some .NET windows forms which I am trying to display in full screen mode (i.e. takes up the entire display, start bar and all), yet I"m having difficulties getting it to display on the correct monitor.  

My code looks as per the code snippet attached.  As you can see, I've tried both setting both the Location and the Bounds properties of the form, both of which _appear_ to place the form in the correct position, i.e. its location property becomes 1024,0 in 1024x768 res.  However, when the form is rendered, it still appears on the primary screen.  If I switch the check in the GetSecondaryScreen method to return the primary screen, rather than the secondary, the result is exactly the same; it still fills up the monitor.
public FullScreenForm()
		{
			Screen displayScreen = GetSecondaryScreen();
			if (displayScreen != null)
			{
				// Properties needed for full screen-ness.
				this.MaximizeBox = false;
				this.MinimizeBox = false;
				//this.TopMost = true;
				this.FormBorderStyle = FormBorderStyle.None;
 
				// Place the window in the secondary screen
				this.Size = new System.Drawing.Size(displayScreen.WorkingArea.Width, displayScreen.WorkingArea.Right);
 
				//this.Location = screen.WorkingArea.Location;
				this.Bounds = new System.Drawing.Rectangle(
					displayScreen.WorkingArea.X, displayScreen.WorkingArea.Y, displayScreen.WorkingArea.Width, displayScreen.WorkingArea.Right);
 
			}
		}
 
		private Screen GetSecondaryScreen()
		{
			if (Screen.AllScreens.Length <= 1)
			{
				return null; 
			}
			foreach (Screen screen in Screen.AllScreens)
			{
				if (!screen.Primary)
				{
					return screen;
				}
			}
 
			return null;
		}

Open in new window

0
Comment
Question by:neotechnology
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
DarrenD earned 2000 total points
ID: 24105538
Hi,

I have two forms that I display on two seperate monitors.

On each form at design time I specify the following:

FormBorderStyle = None
StartPosition = Manual

Then I have a main form which I load the other two forms. I use the following code

  Private Sub ShowForm1()

    MyFrm1.Location = New System.Drawing.Point(20, 100)
    MyFrm1.WindowState = FormWindowState.Maximized
    MyFrm1.ShowDialog()

  End Sub

  Private Sub ShowForm2()

    MyFrm2.Location = New System.Drawing.Point(1500, 100)
    MyFrm2.WindowState = FormWindowState.Maximized
    MyFrm2.ShowDialog()

  End Sub

I know this is VB.NET but I'm sure you get it.

Hope this helps,

Darren
0
 

Author Closing Comment

by:neotechnology
ID: 31568415
Thanks for that, solved my problem.  The hint was that I was trying to set the Location property in the constructor, which was being changed once I called Show() on the form.  I've since created a new method for showing, and set the Location in that before calling Show(), now it works fine.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question