Mouse click...

Hi there. I need help with a little problem.
I have a program that creates/maintains a database with bunch of records. The problem is that there are many records, and if i want to get to lets say record 30, i need to click on my NEXT button 30 times. My question is, is there a way to keep scrolling once the user pushes and doesnt release the NEXT button? I found a way, not sure if thats the best way - i used a timer. Heres a piece of code that i used to make that happen.

Private Sub cmdNext_Click()
'Checking for END OF FILE
'if not, then show the next record
If rs.EOF = False Then
rs.MoveNext
Else
'if this is END OF FILE, then imitate a click on a button
'that moves the current position to first record
cmdFirst_Click
End If
'Checking for position after the MoveNext command
'intTotal holds the total number of records
If rs.AbsolutePosition < 0 Then cmdFirst_Click
If rs.AbsolutePosition >= intTotal Then cmdLast_Click
'RefreshDat sub updates all the fields with the data
'from the record in the current position
Call RefreshDat
End Sub

Private Sub cmdNext_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)
'Initialise timer
Timer1.Enabled = True
End Sub
Private Sub cmdNext_MouseUp(button As Integer, Shift As Integer, X As Single, Y As Single)
'timer off
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
cmdNext_Click
End Sub

I set the Interval property of timer1 to 100 so that the scrolling doesnt go too fast. This works, of course, only with the next button. I can make it work with the previous button too - with a global boolean variable i guess. The question is - is there an easier way to do the task? I tried playing around with the mousedown/mousemove events, but no luck so far.
Thanks for any help!
James R.

Comments

  • well, you got it right. but mouse_move is useless. Mouse_down will do the trick. The timer can be deleted. You could use another variable that increases with small values like 0.001, this must be a double or something... When the mouse is down just use the small increase value for delaying the scroll.




    : Hi there. I need help with a little problem.
    : I have a program that creates/maintains a database with bunch of records. The problem is that there are many records, and if i want to get to lets say record 30, i need to click on my NEXT button 30 times. My question is, is there a way to keep scrolling once the user pushes and doesnt release the NEXT button? I found a way, not sure if thats the best way - i used a timer. Heres a piece of code that i used to make that happen.
    :
    : Private Sub cmdNext_Click()
    : 'Checking for END OF FILE
    : 'if not, then show the next record
    : If rs.EOF = False Then
    : rs.MoveNext
    : Else
    : 'if this is END OF FILE, then imitate a click on a button
    : 'that moves the current position to first record
    : cmdFirst_Click
    : End If
    : 'Checking for position after the MoveNext command
    : 'intTotal holds the total number of records
    : If rs.AbsolutePosition < 0 Then cmdFirst_Click
    : If rs.AbsolutePosition >= intTotal Then cmdLast_Click
    : 'RefreshDat sub updates all the fields with the data
    : 'from the record in the current position
    : Call RefreshDat
    : End Sub
    :
    : Private Sub cmdNext_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)
    : 'Initialise timer
    : Timer1.Enabled = True
    : End Sub
    : Private Sub cmdNext_MouseUp(button As Integer, Shift As Integer, X As Single, Y As Single)
    : 'timer off
    : Timer1.Enabled = False
    : End Sub
    :
    : Private Sub Timer1_Timer()
    : cmdNext_Click
    : End Sub
    :
    : I set the Interval property of timer1 to 100 so that the scrolling doesnt go too fast. This works, of course, only with the next button. I can make it work with the previous button too - with a global boolean variable i guess. The question is - is there an easier way to do the task? I tried playing around with the mousedown/mousemove events, but no luck so far.
    : Thanks for any help!
    : James R.
    :
    :

    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]

  • Actually, it's just my opinion, the better way is to use ADO or any Grid, ListView controls. All of them've already had scroll bar.

    : well, you got it right. but mouse_move is useless. Mouse_down will do the trick. The timer can be deleted. You could use another variable that increases with small values like 0.001, this must be a double or something... When the mouse is down just use the small increase value for delaying the scroll.
    :
    :
    :
    :
    : : Hi there. I need help with a little problem.
    : : I have a program that creates/maintains a database with bunch of records. The problem is that there are many records, and if i want to get to lets say record 30, i need to click on my NEXT button 30 times. My question is, is there a way to keep scrolling once the user pushes and doesnt release the NEXT button? I found a way, not sure if thats the best way - i used a timer. Heres a piece of code that i used to make that happen.
    : :
    : : Private Sub cmdNext_Click()
    : : 'Checking for END OF FILE
    : : 'if not, then show the next record
    : : If rs.EOF = False Then
    : : rs.MoveNext
    : : Else
    : : 'if this is END OF FILE, then imitate a click on a button
    : : 'that moves the current position to first record
    : : cmdFirst_Click
    : : End If
    : : 'Checking for position after the MoveNext command
    : : 'intTotal holds the total number of records
    : : If rs.AbsolutePosition < 0 Then cmdFirst_Click
    : : If rs.AbsolutePosition >= intTotal Then cmdLast_Click
    : : 'RefreshDat sub updates all the fields with the data
    : : 'from the record in the current position
    : : Call RefreshDat
    : : End Sub
    : :
    : : Private Sub cmdNext_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)
    : : 'Initialise timer
    : : Timer1.Enabled = True
    : : End Sub
    : : Private Sub cmdNext_MouseUp(button As Integer, Shift As Integer, X As Single, Y As Single)
    : : 'timer off
    : : Timer1.Enabled = False
    : : End Sub
    : :
    : : Private Sub Timer1_Timer()
    : : cmdNext_Click
    : : End Sub
    : :
    : : I set the Interval property of timer1 to 100 so that the scrolling doesnt go too fast. This works, of course, only with the next button. I can make it work with the previous button too - with a global boolean variable i guess. The question is - is there an easier way to do the task? I tried playing around with the mousedown/mousemove events, but no luck so far.
    : : Thanks for any help!
    : : James R.
    : :
    : :
    :
    : [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    :
    :

  • Any particular advantage with using the variable over the Timer? Cause my C++ always pointed out how good it is to try to eliminate every and each variable that is not required. Then again, this aint C++..
    About Dao/Ado control - my other teacher said approximately the same about controls. Any specific advantage of using the control bar over my direct access method? I like to know not only the best method, but also why it is the best :) - gets me in trouble sometimes though cause people think im questioning their style hehe
    Thn for your help folks!
    James R.

    : Actually, it's just my opinion, the better way is to use ADO or any Grid, ListView controls. All of them've already had scroll bar.
    :
    : : well, you got it right. but mouse_move is useless. Mouse_down will do the trick. The timer can be deleted. You could use another variable that increases with small values like 0.001, this must be a double or something... When the mouse is down just use the small increase value for delaying the scroll.
    : :
    : :
    : :
    : :
    : : : Hi there. I need help with a little problem.
    : : : I have a program that creates/maintains a database with bunch of records. The problem is that there are many records, and if i want to get to lets say record 30, i need to click on my NEXT button 30 times. My question is, is there a way to keep scrolling once the user pushes and doesnt release the NEXT button? I found a way, not sure if thats the best way - i used a timer. Heres a piece of code that i used to make that happen.
    : : :
    : : : Private Sub cmdNext_Click()
    : : : 'Checking for END OF FILE
    : : : 'if not, then show the next record
    : : : If rs.EOF = False Then
    : : : rs.MoveNext
    : : : Else
    : : : 'if this is END OF FILE, then imitate a click on a button
    : : : 'that moves the current position to first record
    : : : cmdFirst_Click
    : : : End If
    : : : 'Checking for position after the MoveNext command
    : : : 'intTotal holds the total number of records
    : : : If rs.AbsolutePosition < 0 Then cmdFirst_Click
    : : : If rs.AbsolutePosition >= intTotal Then cmdLast_Click
    : : : 'RefreshDat sub updates all the fields with the data
    : : : 'from the record in the current position
    : : : Call RefreshDat
    : : : End Sub
    : : :
    : : : Private Sub cmdNext_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)
    : : : 'Initialise timer
    : : : Timer1.Enabled = True
    : : : End Sub
    : : : Private Sub cmdNext_MouseUp(button As Integer, Shift As Integer, X As Single, Y As Single)
    : : : 'timer off
    : : : Timer1.Enabled = False
    : : : End Sub
    : : :
    : : : Private Sub Timer1_Timer()
    : : : cmdNext_Click
    : : : End Sub
    : : :
    : : : I set the Interval property of timer1 to 100 so that the scrolling doesnt go too fast. This works, of course, only with the next button. I can make it work with the previous button too - with a global boolean variable i guess. The question is - is there an easier way to do the task? I tried playing around with the mousedown/mousemove events, but no luck so far.
    : : : Thanks for any help!
    : : : James R.
    : : :
    : : :
    : :
    : : [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    : :
    : :
    :
    :

  • : About Dao/Ado control - my other teacher said approximately the same about controls. Any specific advantage of using the control bar over my direct access method? I like to know not only the best method, but also why it is the best :) - gets me in trouble sometimes though cause people think im questioning their style hehe
    :
    For me, there is just one but very important advantage - it's already done and works fine. Therefore, there is no reason to change it. At the mean time, if you want, you can continue your experiment.
  • : : About Dao/Ado control - my other teacher said approximately the same about controls. Any specific advantage of using the control bar over my direct access method? I like to know not only the best method, but also why it is the best :) - gets me in trouble sometimes though cause people think im questioning their style hehe
    : :
    : For me, there is just one but very important advantage - it's already done and works fine. Therefore, there is no reason to change it. At the mean time, if you want, you can continue your experiment.
    :
    Ah ok then :)
    Since Im already almost finished with this project, ill keep using my current method, but I will keep in mind the data control method for my future projects. Thanks again for your help
    James R.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories