C# -- Determining the dimensions of the users screen that a form is launched on and making the forms dimensions 1/4 the screen area.

Posted on 2005-04-04
Medium Priority
Last Modified: 2008-02-01
Hi folks,

Hi I am fairly new to programming so if you could show me by code example and very plain english of what it is doing I would appreciate it very much.  Anyway...

I was wondering.  I am writing an app where I want to launch a form with the width of the form 1/2 the width of the users screen (pixels I guess) and 1/2 the height for a total of exactly 1/4 the surface area of the computer screen the app is run on.

Also how could I (what would the code look like if I wanted to launch it at a specific position.

Lastly, how can I (in code) tell if there are X number of instances of a particular form so that if let's say I had 9 instances instead of 4 (example of 1/2 dimension and 1/4 surface area example) I could have the the nine forms tiled (3X3) so that the width and hight of each form would be reset (if user presses a button of course  :)   ) to 1/3 with each form taking up 1/9th of screen size (resolution/pixels whatever)

event   buttton press
how many instances of a form are there...
equally size each by users screen size...
tile them approprietly etc...

The example of stuff I am trying to figure out above is to tile windows of a financial charting application etc.

Please allow me to express my huge thanks in advance for your efforts.


Question by:Dynotoe
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

Expert Comment

ID: 13699531
your problem be solved if I show you a code to get the Screen Resolution ( such as 800 x 600 or other ) ?

Assisted Solution

Wim_Bl earned 600 total points
ID: 13699593

can this help ?

screenHeight = screen.WorkingArea.Height
screenWidth = screen.WorkingArea.Width

' Show the TaskPane2 form and initially size it to take up
' half the screen.
With Me .Show()
    .Height = screenHeight
    .Width = screenWidth / 2
    .Top = 0
    .Left = screenWidth / 2
End With

Change the Top and Left properties to place the form somewhere else. In your main application, keep a reference to each file you open. When the user presses a button, check the number of files open, add one to it and then recalculate the sizes. Finally,
redraw the forms with their new size. Hope this gets you going.


Author Comment

ID: 13699827
hi Wim_BL,

I'm not familiar with


end with"

is this VB?  What is it in C#?  Also.. How does your code work with my code (can you incorporate it)  

FYI....Form3 is the form I want to size.  Form2 calls the method in Form1 that lauches form3 by this type of code...

Form3 f3 = new Form3();

where does your code come in?  should I place the sizing in the form3 load event instead?

Lastly is there any code that can reference and return the number of instances of form3 that are running in runtime mode?

Thanks for the qucik response.



Accepted Solution

melodiesoflife earned 1400 total points
ID: 13703453
Please try this code.

private void Form1_Load(object sender, System.EventArgs e)
      this.Width = SystemInformation.PrimaryMonitorSize.Width / 2;
      this.Height = SystemInformation.PrimaryMonitorSize.Height / 2;

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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