Single click / double click

  • Thread starter Thread starter Adam J. Rosen
  • Start date Start date
A

Adam J. Rosen

I am writing a forms program with a notify icon in the system tray. I have
event handlers for both OnClick and OnDoubleClick. However, when you double
click on the icon, it fires the OnClick event as well. I tried implementing
this through a OnMouseUp event, and use the MouseEventArgs.Clicks counter,
but that's always set to 0. Can anyone help me treat a click and a
doubleClick as separate events?

Thanks

Adam J. Rosen
 
I can get e.clicks == 1 or 2 on the mouseDown event (not sure why it always
shows 0 on the MouseUp event). However, a double click will fire MouseDown
twice - once with e.clicks = 1, and once with e.clicks=2. But I don't want
to do my single click logic on what is going to be a double click.

The only thing I can think of is on a singleClick, set a timer for the
double_click interval of windows (don't even know how to find that though).
If a double click event comes, kill the timer. If the timer fires, it was a
single-click only event, and do the singleClick logic then. But isnt' there
a more native way to find this? It seems like very basic functionality, I
would expect it to be simpler. The volume system tray icon works this way
(one click gives a delay and then the volume slider, double click gives the
volume control) as well as other tray icons I've seen... I just expected a
simple function call to find out.

Any more suggestions are greatly appreciated.

Adam
 
Back
Top