Results 1 to 4 of 4

Thread: Button Press

  1. #1

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    Button Press

    Hi,

    I've got two command buttons that I use to control the volume of my app.

    At the moment the user presses the applicable button and the volume is adjusted either up or down.

    I want to allow the user to keep the button pressed down and adjust the volume accordingly rather than having to repeatedly press the button.

    Is there a way to do this?

    Regards
    VB.Net (VS 2010)

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    There is one click event when the button is pressed, so that is out of the question. The solution will be trickier. What you might try doing, is starting a timer on the click event, such that every time the timer event occurs, you check to see if the mouse is still down (maybe a flag altered by some of the mouse events), and altering the volume if it is.

    Another thing you might consider is the slider control. I realize that an up and down button is an intuitively correct way to handle volume, but the slider control would be as well, and the user would get visual feedback about what they are doing.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Here's a clue:

    VB Code:
    1. Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Timer1.Interval = 100
    3. Timer1.Enabled = True
    4.  
    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.  
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13. 'Code here to increase/decrease volume
    14.  
    15. End Sub

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Yeah, like that, but I think the interval ought to be longer. If you've ever seen anybody who's really bad at playing Quake, setting the interval to 0.1 seconds would have that person adjusting the volume like it was a wawa pedal.

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