Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# 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
431 Views
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.

Regards,

Dynotoe
0
Question by:Dynotoe

LVL 1

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 ) ?
0

LVL 9

Assisted Solution

Wim_Bl earned 600 total points
ID: 13699593
Hi,

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.

greetings
0

Author Comment

ID: 13699827
hi Wim_BL,

I'm not familiar with

"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();
f3.Show();

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.

Best,

Dynotoe
0

LVL 6

Accepted Solution

melodiesoflife earned 1400 total points
ID: 13703453

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

}
0

## Featured Post

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
###### Suggested Courses
Course of the Month14 days, left to enroll