Results 1 to 9 of 9

Thread: Scroll Bar Position??

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Montreal, Quebec
    Posts
    51

    Scroll Bar Position??

    How do I go about moving a vertical and horizontal scroll bar. I want to move them in from the border of the form...towards the center. (About a centimeter) Any suggestions?

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    are you using a Vertical Scrollbar control??

    if so do this:

    VB Code:
    1. VScroll1.Left = Me.ScaleWidth - 200

    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    If you always want it to be in proportion you can use a percentage instead of a hard coded number.

    VB Code:
    1. ' 5% from right border
    2. VScroll1.Left = 0.95 * Me.ScaleWidth - vscroll1.width

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Montreal, Quebec
    Posts
    51

    Scroll Bar Position

    I was wondering if scroll bars automatically move to the edges of your form during runtime...Regardless of the monitor size or resolution.

    Basically, would the scroll bars on my screen(17") be in the same position of the form as they would on a 14" screen.

    Thanx

  5. #5
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Controls on forms don't automatically size. You have to use the resize event of the form. Do this. Create a form with a text box (text1) and a command button (command1).

    Past this code in the form resize event and play with resizing the form. This gets really complicated when you have a lot of controls. That's why it's best to use percentages if you really want everything to resize.

    VB Code:
    1. Sub Form1_Resize
    2. Const iBorder as integer =180
    3.  
    4. with Command1
    5.     .left = scalewidth  - (.width + iBorder)
    6.     .top = scaleheight - (.height + iBorder)
    7. end with
    8.  
    9. with Text1
    10.     .left = iBorder
    11.     .top = iBorder
    12.     .width = scalewidth - (.left + iBorder)
    13.     .height = scaleheight - (command1.height + 2 * iBorder)
    14. end with
    15.  
    16. End Sub

  6. #6
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    TIP:

    if you're going to be changing more than one Left, Top, Width or Height value of a control, then use the Move method instead.

    i.e.
    VB Code:
    1. Command1.Move 0, 0, 1000, 1000
    it will be about 4 times quicker than
    VB Code:
    1. Command1.Left = 0
    2. Command1.Top= 0
    3. Command1.Width = 1000
    4. Command1.Height = 1000

    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  7. #7
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    I'm sure it is, that's how all my old code is written and it happens in an extremely small fraction of a blink. I've started using Move for new code though.

  8. #8
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    Originally posted by cafeenman
    I'm sure it is, that's how all my old code is written and it happens in an extremely small fraction of a blink. I've started using Move for new code though.


    you're right it doesnt usually make any difference, just that the form's paint event fires each time you change one of the properties or use the Move event.
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  9. #9
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    oooh... I didn't know that.

    Thanks.

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