How to detect the double click by mouse?

Hi! Delphi forms can trap the events such as OnClick, OnMouseDown, OnMouseUp, but nothing is related to double click directly. Is it possible to trap the double click? Shall I use some routine related to time?
Thank you!

Comments

  • : Hi! Delphi forms can trap the events such as OnClick, OnMouseDown, OnMouseUp, but nothing is related to double click directly. Is it possible to trap the double click? Shall I use some routine related to time?
    : Thank you!
    :
    Sure. A form has an OnDblClick message that you can trap. In fact, most of the widgets in Delphi have it.
  • Thank you!
    But this function doesn't have X,Y coordinates as parameters. If I only want to detect the double click to certain area, what shall I do?

  • : Thank you!
    : But this function doesn't have X,Y coordinates as parameters. If I only want to detect the double click to certain area, what shall I do?
    :
    :
    Do you mean some arbitrary X,Y position within the form or is the mouse expected to be over a label or picture? If the latter, that's easier, just trap the OnDblClick message of the picture or label. If you're just out in the client area of the form, look up the wm_NCHitTest or cm_NCHitTest messages in the Windoze API help that comes with Delphi. Those return screen coordinates, so you'll have to convert to form coordinates with the ScreenToClient API function. It's much easier to use a label or picture. - HTH
  • : : Thank you!
    : : But this function doesn't have X,Y coordinates as parameters. If I only want to detect the double click to certain area, what shall I do?
    : :
    : :
    : Do you mean some arbitrary X,Y position within the form or is the mouse expected to be over a label or picture? If the latter, that's easier, just trap the OnDblClick message of the picture or label. If you're just out in the client area of the form, look up the wm_NCHitTest or cm_NCHitTest messages in the Windoze API help that comes with Delphi. Those return screen coordinates, so you'll have to convert to form coordinates with the ScreenToClient API function. It's much easier to use a label or picture. - HTH
    :
    You could also try to trap the WM_LBUTTONDBLCLK message. This could also be used to respond to right double clicks, or shift/control double clicks. The message also contains the screen coordinates.
  • Thank you!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories