Results 1 to 13 of 13

Thread: When MouseButton Down then repeat action until MouseButton released

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    When MouseButton Down then repeat action until MouseButton released

    MouseDown.

    I want to skip the records with the Mouse. This is no Problem, but i have to click for every Record again. I want to press the MouseButton and as long as i dont release the Button the Records have to skip (the Sub have to be called again).

    A sample sourcecode would be very nice .....



    I would be VERY happy if an expert here can answer this questions.

    Nice greetings from Bangkok

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    what control are u using to navigate ? a command button or a datacontrol directly ?
    -= a peet post =-

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    i want to click on a command button

    Hi, thanks for your fast answer,

    i want to click on a commend button that have behind a sourcecode to skip records.

    But i am generally interested how to handle it if i click on any kind of button to repeat the action.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    This assumes that you have code to display your records as they are moving along, and that you have a recordset of the records that you want displayed. It also assumes you are using a command button to zip throught the recordset. Something like this should work for you.
    VB Code:
    1. Option Explicit
    2.  
    3. Private StopIt As Boolean
    4.  
    5. Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6.              Do While StopIt = False
    7.                 Rs.MoveNext
    8.              Loop
    9. End Sub
    10.  
    11. Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.  StopIt = True
    13. End Sub

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    wow Hack, u'r on a roll today
    -= a peet post =-

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Thanks Hack,

    Hi,

    unfortunatly the repeat is so fast that i cant use it. I would like to skip records in this way.
    But with this repeat it needs only 1 second to skip 1000 records, hehe.

    You got any idea, how i make it that i can skip continiously records, but not to fast?

  7. #7
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    DoEvents

    or Sleep or wait or something

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Are there any sequential numbers involved in your records, like an index starting at 1 and going to the last record in the Db? My thought is that if you have records somehow numbered from 1 to say 10,000 then you could move directly to a specified record number, and on the next click, add a 1000 to the record number you are on now, and move directly to it.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Hi

    There is an index on the records and they are around 1000.

    All what i want is that the user don't have to release always the mous button when he skip records. It is much more comfortable to hold the button down until he comes to this area where he want to go. But the speed is to fast for it. It needs less then 1 second to go through the records and on the screen is no update to see when he skip the records.

    Any idea how to solve this problem that the records get skipped by holding down the button in a reasonable speed?

    I would be very happy if somebody know it.

    Franky
    Happy new year to you

  10. #10
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    You could try putting the rs.NoveNext method inside a timer event set the intervals to whatever speed you want. In the mouse down event of the command button, enable the timer. In the mouse up event disable the timer.

  11. #11
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Catalonia
    Posts
    397
    Look at this Hack code modification to see if it does what you want
    VB Code:
    1. Public Declare Function GetTickCount Lib "kernel32" () As Long
    2.  
    3. Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    4. Dim TimeDelay As Integer
    5. Dim Start As Long
    6. TimeDelay = 500 ' half second
    7. Start = GetTickCount
    8. Do While StopIt = False
    9.     DoEvents
    10.     If GetTickCount > Start + TimeDelay Then
    11.         Rs.MoveNext
    12.         Start = GetTickCount
    13.     End If
    14. Loop
    15. End Sub
    Josep Mª

  12. #12
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Use this Pause Sub. interval is from 0.0001 all the way up to a whole day heh.

    Sub Pause(interval)
    current = Timer
    Do While Timer - current < Val(interval)
    DoEvents
    Loop
    End Sub

    Dim StopLoop as Boolean
    -------------------------------------------------------------------------
    Mouse_Down
    StopLoop=False

    Do Until StopLoop= True
    Pause(0.1)
    'More Code
    Loop
    -------------------------------------------------------------------------
    Mouse_Up
    StopLoop=True
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  13. #13
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    4.     Timer1.Enabled = True
    5. End Sub
    6.  
    7. Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8.     Timer1.Enabled = False
    9. End Sub
    10.  
    11. Private Sub Form_Load()
    12.     Timer1.Interval = 200
    13.     Timer1.Enabled = False
    14. End Sub
    15.  
    16. Private Sub Timer1_Timer()
    17.     rs.MoveNext
    18. End Sub

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