Center Form Stretching

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    Center Form Stretching

    Hi all,
    I m stretching my form and i want if i stretch its position after stretching must be in middle of screen or i want to stretch centerly.

    Thanx
    >> ALI <<
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by Ali Rizwan
    Hi all,
    I m stretching my form and i want if i stretch its position after stretching must be in middle of screen or i want to stretch centerly.

    Thanx
    >> ALI <<
    Set the start up position to center?

    Comment

    • Ali Rizwan
      Banned
      Contributor
      • Aug 2007
      • 931

      #3
      I want this at runtime......

      thanx

      Comment

      • daniel aristidou
        Contributor
        • Aug 2007
        • 494

        #4
        Originally posted by Ali Rizwan
        I want this at runtime......

        thanx
        Okk.....this is a genral formula

        Get the screen size (width)
        Divide screen size by 2
        Get form size (width)
        Divide screen size by 2

        Set the form position.left = (0.5 * Screensize) + (0.5 * Form width)
        Do the same for the hieght

        Hope this helps

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Correction.

          Rather than...
          Set the form position.left = (0.5 * Screensize) + (0.5 * Form width)
          I'm fairly certain it should be...
          Set the form position.left = (0.5 * Screensize) - (0.5 * Form width)

          Comment

          • daniel aristidou
            Contributor
            • Aug 2007
            • 494

            #6
            Originally posted by Killer42
            Correction.

            Rather than...
            Set the form position.left = (0.5 * Screensize) + (0.5 * Form width)
            I'm fairly certain it should be...
            Set the form position.left = (0.5 * Screensize) - (0.5 * Form width)
            Yep your correct killer......

            Comment

            Working...