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

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.

Regards,

Dynotoe
DynotoeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MOH_RCommented:
your problem be solved if I show you a code to get the Screen Resolution ( such as 800 x 600 or other ) ?
0
Wim_BlCommented:
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
DynotoeAuthor Commented:
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
melodiesoflifeCommented:
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;
            
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.