How to hijack an event handler?

In C#, can i create an event handler based on how long a user holds a mouse button?

  • -- PREFACE -- I am new to programmig :) -- I want to create an event handler based on how long a user presses and holds down a mouse button. When a user holds down a mouse button for 1.5seconds, on any file, the file would open and/or is read using something like File.ReadAllBytes. Is this possible in C#? Thanks!

  • Answer:

    In the MouseDown event, record the system time. In the MouseUp event, compare the current time to the recorded system time to see how long the mouse was down for. Use that to determine what to do (which method to call, etc.)

Luke at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.