screen resolution

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pranavjog
    New Member
    • Jun 2008
    • 1

    screen resolution

    Resize a form & controls on it depending on the screen resolution
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    Could you tell us what version?

    I asume your using VB?

    James

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      Code:
       
      'VB      
      Dim x, y as Int32
       x = SystemInformation.PrimaryMonitorSize.Width
      y = SystemInformation.PrimaryMonitorSize.Height
      Me.Size = New Size(x - 20, y - 20)
      Code:
      //c#
      int x = SystemInformation.PrimaryMonitorSize.Width;
      int y = SystemInformation.PrimaryMonitorSize.Height;
      this.Size = new Size(x - 20, y - 20);
      would set your form to 20 pixels less than your resolution in both dimensions. You can use similar logic to change the size of your controls.

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        Here's another example from vb2005

        [code=vb]
        Dim a As Rectangle = Screen.PrimaryS creen.WorkingAr ea
        'Size form
        Me.Width = a.Width
        Me.Height = a.Height
        'Position form
        Me.Top = 0
        Me.Left = 0
        [/code]

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          There is also:
          Code:
          Screen.AllScreens
          Which gives an array of screens to check for screen resolutions on.


          I think there is also a way to tell which screen your window currently resides on, but I cannot seem to find it.

          Comment

          Working...