Single vs. Doucble Click

  • Thread starter Thread starter Thom Little
  • Start date Start date
T

Thom Little

I would like three states on an icon ...

Left Click
Right Click
Double Click

Left Click is fired at least once on a Double Click

Is there a good example that shows how to determine if the user entered a
Left Click or a Double Click?
 
I am not sure what control you are using but my best suggestion would be to
derive from the control you want to use, and lets just it's the picturebox
control. I would add the three properties you want to keep track of, and
within the onClick, and onDoubleClick methods. I would modify the state of
those three properties.


Keenan
 
Maybe wait for a set period to see if the next click comes?
You would not be able to do this in the event handler but would have to
start a "process" that would be cancelled by the double click.
Maybe start a timer and in the timer event set the click icon and in the
double click event stop the timer.
HTH
JB
 
Hi Thom,

Based on my understanding, you want to distinguish left click with double
click.

Can your tell me what is your "icon"? Is it a WinForm control?

For a control, you may handle this through Control.Click event and
DoubleClick event. Or you may override the control, handle in both OnClick
and OnDoubleClick protected method.

Does this meet your need?

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I am using System.Windows.Forms.NotifyIcon and would like to service events
for ...

Left Click
Right Click
DoubleClick

I do not currently have Left Click enabled.
DoubleClick works fine.
Right Click is assigned to the context menu and it works fine.

If I enable Left Click it is raised ...

Once for a Left Click
Twice for a DoubleClick
Once for a Right Click

Is there an obvious routine for isolating this behavior to easily determine
a ...

Left Click
Left DoubleClick
Right Click
Right DoubleClick
 
Hi Thom,

Thanks for your feedback.

Based on my understanding, I think you do not want the single click logic
when double click occurs.

==============================
Actually, in windows system, all events are driven by messages. For mouse
events, if you double click your mouse, the single click message will first
occur for you.
This is by design. Because double click is consistute of 2 single click,
which click internal is less than certain value. When the first single
click occurs, the system can not know if it is a "pure" single click or is
just a "part" of double click. So system also will fire single click for
you.

For your request, the only workaround I can think of is delay the single
click code logic. That is: when single click occurs, we can delay a certain
time, to see if another single click is comming, if it comes, we discard
the single click code, but process the double click logic. But if there is
no another single click occurs, we can just process the single click logic.

The key point is to determine the "certain" time to delay. This time should
be a little longer than the system double click time.(Which is stored in
windows system, you can configure it through control panel). In C#, we can
P/invoke GetDoubleClickTime Win32 API to get this value. Then you can use
Timer control to do the delay.

==============================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks for the lead.

I did it with a timer and testing ButtonDown for a Left Click.

I then abandoned the capability.

The icon is too small and the mouse clicking has to be too precise. In
addition the timing will vary from machine to machine and I think it will be
prone to failure.

I settled for double-click and single right click for my application.
 
Hi Thom,

Thanks very much for your feedback.

Do you still have any concern on this issue? If you need further help,
please feel free to feedback, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I revisited this requirement and tweaked the installation. The final
implementation supports the following actions on an icon in the System Tray
....

Left Click
Left Double Click
Right Click

This was the original design and it operates very nicely.

For the double click time interval I simply use ...

timeLeftClick.Interval = SystemInformation.DoubleClickTime ;

Thanks for the help.
 
Hi Thom,

Oh, cool, I did not see there is a so easy way to get this value. Cheers!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top