Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 ListBox Click and DblClick

Tags:

vb6

I have a need to run different code when a user clicks or double-clicks an item in a VB6 ListBox control. When I click on the control, the Click event handler executes. However, I am finding that when I double-click on the control, both the Click and DblClick event handlers execute.

Anyone have a good solution for getting just the DblClick event handler code to run without the Click code being executed first?

Thanks in advance for any suggestions.

like image 357
E Brown Avatar asked May 20 '26 12:05

E Brown


1 Answers

A slight hack, but you could use a Timer control and a boolean variable:

  • Start the timer on the Click event, set the boolean variable to false
  • Set the boolean variable to true on the DoubleClick event
  • When the timer Tick event fires, check the boolean variable to see if the user did a Click or DoubleClick

I'd recommend setting the timer interval to the Windows double click time setting, plus a bit (There should be a Windows API call that will give you this value).

like image 63
Richard Ev Avatar answered May 26 '26 07:05

Richard Ev