Results 1 to 4 of 4

Thread: Scrollbars

  1. #1

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604

    Arrow

    hi,

    i have just had a thought <gasp in amazment>, is it possible to detect when the scrollbar hs reached the bottom, ie the user has scrolled the object to the bottom, becasue i have a lisence agreement i want the next button to be enabled when the user has scrolled to the bottom of the page

    Cheers

    Merlin ?

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I assume you want to know how to do this with a TextBox.
    Then here's one way of doing it.
    Add a Timer to the form and add the following code:
    Code:
    Private Declare Function SendMessage _
     Lib "user32" Alias "SendMessageA" ( _
     ByVal hwnd As Long, _
     ByVal wMsg As Long, _
     ByVal wParam As Long, _
     lParam As Any) As Long
    
    Private Const EM_GETFIRSTVISIBLELINE = &HCE
    
    Private lngLine As Long
    
    Private Sub Form_Load()
        'Load your text box with the text first!!!!
        'The text you want to show must be in the text box
        'before continuing with this code.
        Timer1.Enabled = False
        'The text box must be visible for this to work
        'so if you (like in this example) add this code
        'to Form_Load you must first show the form.
        Me.Show
        DoEvents
        Text1.SelStart = Len(Text1)
        DoEvents
        lngLine = SendMessage( _
         Text1.hwnd, _
         EM_GETFIRSTVISIBLELINE, _
         0&, 0&)
        Text1.SelStart = 0
        Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
        'This will enable the button (in this example called Command1)
        'when the user has reached the bottom of the text
        Command1.Enabled = (SendMessage( _
                            Text1.hwnd, _
                            EM_GETFIRSTVISIBLELINE, _
                            0&, 0&) = lngLine)
    End Sub
    Good luck!

  3. #3
    New Member
    Join Date
    Jun 2000
    Location
    South Florida
    Posts
    11

    Cool

    instead of a text box which you still can use....make a picturebox with a label in it and set the label.top to match VScroll top and then you will have to set the max to match the amount of text you need to scroll before the command button is enabled..........

    Private Sub VScroll1_Change()

    'in the form load put this VScroll1.value = 20 or what ever 'you want it to be
    'set the Button you want disabled to false
    'set the text box to match the scrollbar height

    VScroll1.Max = 20
    VScroll1.Min = 0

    If VScroll1.Min = 0 Then
    Command1.Enabled = True
    Else
    End If

    End Sub
    There's only two things universal in this world and thats Hydrogen and Stupidity.

  4. #4
    Guest
    that doesnt really make sense.

    if the min = 0 then let the command button be enabled??

    also if there is nothing to be done after the Else line, you dont need to put it in.

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