I did something similar to this. I created a custom button and used a timer.
I added some additional events to let me know when the time was. I your case
you could have an event fire MouseUp event with the amount of time that
passed since it was clicked.
Something like this:
public delegate void OnElapsedTime(object sender, int elapsedTime)
public event OnElapsedTime ElapsedTime;
MouseDown(object sender, MouseEventArgs e)
{
globalDateTime = DateTime.Now;
}
MouseUpEvent(object sender, MouseEventArgs e)
{
if (ElapsedTime != null)
{
DateTime dt = new DateTime();
TimeSpan ts = DateTime.Now.Subtract(globalDateTime);
ElapsedTime(this, ts.Milliseconds);
}
I didn't compile this code but it should be pretty close.
-Joe
"pantherteeth" <pa**********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I'm writing a little mp3 player shell type thing, and I'm trying to
figure out how to determine how long a button has been pressed.
For example, if a user clicks the left button, the song should be
decremented to the previous one. However, if the user holds the button
down for two seconds, the song would begin rewinding. Further, if the
button is pressed for five seconds, the folder will change to a
previous one.... and so on.
I can't find anywhere that says how to do this. Any suggestions?