PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Scroll bar Help-VBForums
Results 1 to 14 of 14

Thread: Scroll bar Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Scroll bar Help

    Basically, i am making a simple form on VB6
    Its a reg form for an enrollment system.
    Basically, the reg form is to long to fit on the screen and idont want to make another page to continue you registration.
    I need a working scroll bar so i can make the box smaller and i can scroll down the page to fill in the rest of the form.


  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Scroll bar Help

    You'll need to "embed" everything into a PictureBox - it's the easiest way. Check the link in my signature - Scrolling the PictureBox with V&HScrollBars

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Re: Scroll bar Help

    Ugh, means re structuring my whole form.
    Plus i am going to make backgrounds for the forms, so they are all the same.
    I'll just stick with 2 pages i guess
    unless theres another way.
    Thanks anwany dude =]

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Scroll bar Help

    Cut and paste them all in a frame and put that frame into a Picture Box...


    I would also suggest you to make the form little wider ... and also bring some boxes together(like day, month and year) to avoid a scroll bar..

  5. #5
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Scroll bar Help

    I a, working on coding a scroll bar for you. (i've never used 1 b4 but its turning out ok)

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Re: Scroll bar Help

    Quote Originally Posted by moinkhan
    Cut and paste them all in a frame and put that frame into a Picture Box...


    I would also suggest you to make the form little wider ... and also bring some boxes together(like day, month and year) to avoid a scroll bar..
    Yeh i done that before
    justwanted to keep it a certain size, but i will put it together and try another layout

    EDIT: I also got to add more things to the list of details.

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Re: Scroll bar Help

    Quote Originally Posted by Mxjerrett
    I a, working on coding a scroll bar for you. (i've never used 1 b4 but its turning out ok)
    Name of the form is frmstudentreg
    name the scroll bar whatever you want

    Thanks alot btw.

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: Scroll bar Help

    Here's an example I just made (see file attached):

    [Edit], By the way, you have to click on the "Add Input" button like 15 times to make enough textboxes to actually be able to use the scroll bar...
    Attached Files Attached Files
    Last edited by CVMichael; Nov 2nd, 2006 at 09:22 AM.

  9. #9
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,137

    Re: Scroll bar Help

    Here is an example that just changes the top value of each of the control when you scroll the scrollbar
    VB Code:
    1. Option Explicit
    2. Dim intPageLength As Integer
    3.  
    4. Private Sub Form_Load()
    5.     Me.Show
    6.     intPageLength = GetPageHeight
    7.     SetScrollBar
    8. End Sub
    9.  
    10. Private Sub Form_Resize()
    11.     If Me.WindowState <> vbMaximized Then
    12.         VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight
    13.         SetScrollBar
    14.     End If
    15. End Sub
    16.  
    17. Private Function GetPageHeight() As Integer
    18. Dim intBottom As Integer
    19. Dim intTemp As Integer
    20. Dim ctl As Control
    21.  
    22.     'find the lowest control on the page and use that to determine the form size
    23.     For Each ctl In Me.Controls
    24.         If ctl <> VScroll1 Then
    25.             intTemp = ctl.Top + ctl.Height
    26.             If intTemp > intBottom Then
    27.                 intBottom = intTemp
    28.             End If
    29.         End If
    30.     Next ctl
    31.    
    32.     'Add a little padding after the last control
    33.     GetPageHeight = intBottom + (15 * Screen.TwipsPerPixelY)
    34. End Function
    35.  
    36.  
    37. Private Sub SetScrollBar()
    38. Dim intMax As Integer
    39.  
    40.     'set the properties for the scrollbar. don't show it if it isn't needed
    41.     intMax = intPageLength - Me.ScaleHeight
    42.     If intMax > 0 Then
    43.         With VScroll1
    44.             .Visible = True
    45.             .Min = 0
    46.             .Max = intMax
    47.             .LargeChange = Me.ScaleHeight * 0.9
    48.             .SmallChange = Me.ScaleHeight * 0.1
    49.         End With
    50.     Else
    51.         VScroll1.Visible = False
    52.     End If
    53. End Sub
    54.  
    55. Private Sub ScrollControls(ByVal Increment As Integer)
    56. Dim ctl As Control
    57.  
    58.     'Change the top position of all the controls execpt the scroll bar
    59.     For Each ctl In Controls
    60.         If ctl <> VScroll1 Then
    61.             ctl.Top = ctl.Top - Increment
    62.         End If
    63.     Next ctl
    64. End Sub
    65.  
    66. Private Sub VScroll1_Change()
    67. Static intLastValue As Integer
    68. Dim intScrollVal As Integer
    69. Dim intIncrement As Integer
    70.  
    71.     'get the current scroll bar value
    72.     intScrollVal = VScroll1.Value
    73.     'find how much the scroll bar has moved
    74.     intIncrement = intScrollVal - intLastValue
    75.     'save the value of the scroll bar for next time
    76.     intLastValue = intScrollVal
    77.  
    78.     'move all the controls
    79.     ScrollControls intIncrement
    80. End Sub
    81.  
    82. Private Sub VScroll1_Scroll()
    83.     Call VScroll1_Change
    84. End Sub

  10. #10
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Scroll bar Help

    lol that was what i was trying to do lol

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  11. #11

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Re: Scroll bar Help

    MarkT, do i just insert that on to the form?
    and add a scroll bar
    Cheers for the code btw.

  12. #12

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Re: Scroll bar Help

    Quote Originally Posted by CVMichael
    Here's an example I just made (see file attached):

    [Edit], By the way, you have to click on the "Add Input" button like 15 times to make enough textboxes to actually be able to use the scroll bar...
    Hey can you recode this so its just the picture box and scroll bar that scrolls down

    I'm quite new to coding and i'm getting confused at the moment.

  13. #13
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    774

    Re: Scroll bar Help

    I am trying to use MarkT's code to scroll the controls.

    Why would the code skip intPageLength = GetPageHeight?

    it jumps straight from Me.Show to Private Sub Form_Resize().

    VB Code:
    1. Private Sub Form_Load()
    2.     Me.Show
    3.     intPageLength = GetPageHeight
    4.     SetScrollBar
    5. End Sub
    6.  
    7. Private Sub Form_Resize()

  14. #14
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: Scroll bar Help

    Whenever you show a form, it will resize, so of course the Form_Resize() event will triger...

    But when Form_Resize() is done, it sould go back to the next line in the Form_Load(), intPageLength = GetPageHeight

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width