Search Forum
(57415 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


              
Printable Version

C# Form Sizing
By Pavel Tsekov

A form, sizing itself to the borders of the screen working area. I subscribed this article because I had a little problem when I wanted to make my form take the whole free screen working area.

I mean not the whole screen, but only the fre working area. For example if the TaskBar(Start menu) is visible, the working area will be a little bit smaller the the whole screen area.

So if we want our form not to cover the Start menu in windows -> we could use this code :

//Make a form take the whole Screen Working Area
// project created on 01.10.2001 ã. at 06:28
// Author : Pavel Tsekov
using System;
using System.Windows.Forms;
using System.Drawing;

class MainForm : Form
{
	public MainForm()
	{
		//create an object of class Rectangle   (rect)
		Rectangle rect=new Rectangle();		
		//rect get data from the function returning the working area of the screen
		rect=Screen.GetWorkingArea(this);
		//place our form at left
		this.Left=0;
		//place our form at top
		this.Top=0;
		//set the size (width and height) of our form as the size of the screen
		//working area
		this.Size=new Size(rect.Width,rect.Height);
		//set the caption(text) of the form. The size of the working area is displayed
		//and then the size of the whole screen
		this.Text="SCR Working area:" + Screen.GetWorkingArea(this).ToString()+" || SCR Real area: " + Screen.GetBounds(this).ToString();
	}
	
	public static void Main(string[] args)
	{
		Application.Run(new MainForm());
	}
}