Results 1 to 6 of 6

Thread: mouseDown, KeyPress?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    248

    mouseDown, KeyPress?

    I use the Click event and it works like you would expect.
    I use the keypress and it will repeat the event as long as the a key is being held down.

    I use the mouseDown event and it acts like the click. It fires when the mouse button goes down. But it does not repeat while the button is held down.

    How can I make it keep going while the mouse is held down.
    I tried just recalling the event and it worked until it crashed with a stack overflow (all I was doing was puting a random number in the caption).

    Mike

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: mouseDown, KeyPress?

    Post your code so we can see what you are trying to do.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: mouseDown, KeyPress?

    The logic would be to enable a timer that will perform a certain action repetitivly invoked from the mousedown event. Set its interval. Then in the accompaning mouseup event you can disable the timer and it will stop firing.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    248

    Re: mouseDown, KeyPress?

    All I am doing is me.caption=rnd*200
    I expected it to keep looping as long as the mouse was down.

    I am trying to make a fastforward button

    Mike
    Last edited by MikeJoel; Feb 9th, 2006 at 09:45 PM.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: mouseDown, KeyPress?

    This increments a textbox 20 times per second when the button is held down.
    You could use the form caption instead.
    VB Code:
    1. Option Explicit
    2.  
    3. Dim flag As Boolean
    4.  
    5. Private Sub Form_Load()
    6.   Randomize
    7. End Sub
    8.  
    9. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10.   Timer1.Interval = 50
    11.   Timer1.Enabled = True
    12. End Sub
    13.  
    14. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    15.   Timer1.Enabled = False
    16. End Sub
    17.  
    18. Private Sub Timer1_Timer()
    19.   Text1.Text = Rnd * 200
    20. End Sub

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: mouseDown, KeyPress?

    Mike, the reason keypress does and mouse click doesn't is in your bios - the keyboard repeats when keys are held down, the mouse buttons don't. It's just historical - computer keys have repeated almost from the beginning, mouse buttons haven't.

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