Those events are really tied together.
Usually the click event is 'selecting' some object and the double click
event is invoking some default action.
Here's what I'd consider a 'hack', you could use a timer that was started
when you detected the initial click, and had a timeout set to the double
click time (REG:\HKEY_CURRENT_USER\Control Panel\Mouse\DoubleClickSpeed
(DWORD)), which is in milli-seconds.
So some pseudo C# code:
private bool m_doubleClick;
private Timer m_clickTimer = new Timer();
Initialize(..)
{
m_clickTimer.Interval = [value from REG:\HKEY_CURRENT_USER\Control
Panel\Mouse\DoubleClickSpeed] + 50;
// the 50 is so it's slightly more than the actual double click time, test
this
m_clickTimer.Elapsed += new ElapsedEventHandler(OnClickEventHandler);
}
void Form1_OnMouseClick(...)
{
m_doubleClick = false;
m_clickTimer.Enabled = true;
}
void From1_OnMouseDoubleClick(...)
{
m_doubleClick = true;
}
void OnClickEventHandler(...)
{
m_clickTimer.Enabled = false;
if (m_doubleClick)
{
// handle double click event
}
else
{
// handle single click
}
}
Cheers,
Stu
JezB said:
I want a control to respond differently on a MouseClick or a
MouseDoubleClick event. Problem is, when the user double-clicks, the
MouseClick is fired FIRST, and there seems no way of knowing whether it's
the first part of a double-click to avoid doing the stuff that the single
click should do.
I'm sure I'm missing something pretty trivial, but what is it ?