Results 1 to 6 of 6

Thread: [Resolved]Centre Objects...?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Resolved [Resolved]Centre Objects...?

    Hey, I have a picture box that's 11475 in width and 7545 in height. When the form is resized how do I keep it in the very centre of the form?

    Thanks in advance
    Last edited by BefunMunkToloGen; Apr 29th, 2005 at 03:26 PM.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Centre Objects...?

    picture.left = (form.width / 2) - (picture.width /2)

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Centre Objects...?

    Use Screen.Width/Height or Form.Width/Height

    Calculate the center of the x and y location and move it there.

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Centre Objects...?

    You will need to do somthing like this in the form_resize() event

    VB Code:
    1. Private Sub Form_Resize()
    2. Picture1.ScaleMode = vbPixels
    3. Form1.ScaleMode = vbPixels
    4.  
    5. Picture1.Left = (Form1.ScaleWidth / 2) - (Picture1.ScaleWidth / 2)
    6. Picture1.Top = (Form1.ScaleHeight / 2) - (Picture1.ScaleHeight / 2)
    7.  
    8. End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Centre Objects...?

    Sorted cheers . For some reason i was doing frmGame.width - PBox.width / 2

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Centre Objects...?

    Quote Originally Posted by BefunMunkToloGen
    Sorted cheers . For some reason i was doing frmGame.width - PBox.width / 2
    No problem if you could edit your origional post and add resolved to the title that would be great



    Pino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width