locked
Something changes my window's size RRS feed

  • Question

  • Hi there

    Im using windows 7 and visual studio 2008 c#

    Can someone explain me why the size of my windows form changes by itself? Let me explain a little bit more.

    I create a simple windows forms application with form1 and just a label showing me the actual size of the form:

    label1.Text = String.Format("Width = {0}, Height = {1}", this.Width, this.Height);

    i give it the size of 800, 600 in the form's property SIZE

    i run the applicacion

    In windows 7 i get 800,600 good, but  i run it on windows server 2008 or in windows xp and i get 594,478 ???

    i give it the size of 1024,768

    In windows 7 i get 1024,768 ok, but in windows server 2008 or in windows xp and i get 762,614 ???

    i give it the size of 1280,800

    In windows 7 i get 1280,800 ok, but in windows server 2008 or in windows xp and i get 779.639 ???

    Does anybody knows why?

    Help most appreciated

    Saludos

    rubenc

    Monday, October 18, 2010 5:54 PM

Answers

  • Hi,

    I think you can check the AutoScalEMode property of your form.

    If you set the value to  AutoScalEMode.Font(it's the default value), the size of your windows form will change by itself when you run it in different windows with diffenent font size;

    If you set the value to AutoScalEMode.Dpi,the size of your windows form will change by itself when you run it in different windows with diffenent DPI;

    So, I think this the reason why it changes the size ifself when you run it in different environment.

     

    Hope Helps

    Vincin

    • Proposed as answer by Helen Zhou Tuesday, October 26, 2010 8:32 AM
    • Marked as answer by Helen Zhou Friday, October 29, 2010 9:01 AM
    Monday, October 25, 2010 8:17 AM

All replies

  • Hi,

    just a guess:

    What are screenResolutions of the machines and are dpi-settings for Windows on all machines the same?

    (if you set the size-property to values larger than screen-res, it automatically will be reset to ~screenresolution)

        public Form1()
        {
          InitializeComponent();
          this.Size = new Size(2400, 1299);
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
          this.label1.Text = String.Format("Width = {0}, Height = {1}", this.Width, this.Height);
        }
    

    Regards,

      Thorsten

    Monday, October 18, 2010 8:11 PM
  • thank you for your reply

    in the computer with windows 7 i have 1920 x 1200, it alway

    in the xp computer and the windows server 2005 i have 1024 x 768

    but i change it accordingly to my desired windows's size... never the resolution is less than the size.

    But I found out that if i change the AutoScaleMode Property of the form to NONE or INHERIT  it almost stays at the same size in xp and windows server 2008

    1024 x 768  ----> 1014 x 730

    Saludos

    rubenc

    Monday, October 18, 2010 10:50 PM
  • Hello rubenc,

    How about using
              this.label1.Text = String.Format("Width = {0}, Height = {1}", Size.Width, Size.Height);
    instead of 
              this.label1.Text = String.Format("Width = {0}, Height = {1}", this.Width, this.Height);

    Since in MSDN document Control.Size Property , it states:
    On Windows Server 2003 systems, the size of a Form is restricted by the maximum pixel width and height of the monitor.

    Regards,
    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Monday, October 25, 2010 4:03 AM
  • Ruben

    Try setting the size to 1014 x 730 or lesser.

    The available screen size is not the same as the scree size.

     

    with regards

    Ashin Antony

    Monday, October 25, 2010 5:15 AM
  • Hi,

    I think you can check the AutoScalEMode property of your form.

    If you set the value to  AutoScalEMode.Font(it's the default value), the size of your windows form will change by itself when you run it in different windows with diffenent font size;

    If you set the value to AutoScalEMode.Dpi,the size of your windows form will change by itself when you run it in different windows with diffenent DPI;

    So, I think this the reason why it changes the size ifself when you run it in different environment.

     

    Hope Helps

    Vincin

    • Proposed as answer by Helen Zhou Tuesday, October 26, 2010 8:32 AM
    • Marked as answer by Helen Zhou Friday, October 29, 2010 9:01 AM
    Monday, October 25, 2010 8:17 AM
  • Hi Jin,

    If you feel the solution I gave doesn’t real answer your question, please feel free to unmark it and update the thread.

    Regards,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, October 29, 2010 9:08 AM