Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting system's double click timer interval in WPF (value from control panel)

I have a FrameworkElement and I want to perform action A when the user single clicks, and action B when the user double clicks.

Due to the way events are delivered, I always get a single click event which begins action A. After looking around, I found an interesting technique here using a timer to delay the handling of the clicks. However, this example hardcodes the timer to 300 milliseconds, but I would prefer to use the user's "Double-click speed" setting Control Panel's Mouse Properties dialog.

What's the wpf/C# API for getting that value from the system?

like image 971
Shezan Baig Avatar asked Jan 27 '11 15:01

Shezan Baig


2 Answers

You can find the time here: System.Windows.Forms.SystemInformation.DoubleClickTime

You can actually see a full implementation of what you are trying to achieve here:

WPF: Button single click + double click issue

like image 58
ColinE Avatar answered Nov 08 '22 16:11

ColinE


If you don't want reference System.Windows.Forms assembly, you can try this:

    [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern int GetDoubleClickTime();
like image 6
dexiang Avatar answered Nov 08 '22 16:11

dexiang