StPendl StPendl Sep 10, 2007 - "added display of delay time"

How to have a single- and a double-click handler for a listbox

- StPendl StPendl Sep 10, 2007

Most people do not know, that a listbox can respond to a single-click by setting the singleClickSelect property.
You can have a different event handler for single-clicks by adding a branch label ( singleClickSelect [action] ) too.

The problem we have, when using both event handlers, is to know which one to use, because Windows sends the single-click and double-click messages to the control, when double-clicking a listbox item.

Here is a demo for using both event handlers based on the Double Click Demo in Newsletter 126

 nomainwin 

for i = 1 to 10
array$(i) = str$(i)
next

listbox #m.lb, array$(, [DoubleClickAction], 10, 10, 200, 200
statictext #m.txt, "Select an item or double click it.", 10, 220, 200, 20

open "test listbox event handlers" for window as #m
#m "trapclose [quit]"
#m.lb "singleClickSelect [SingleClickAction]"
wait

[SingleClickAction]
calldll #user32, "GetDoubleClickTime", delay as ulong
timer delay, [continue]
wait

[continue]
timer 0
#m.txt "Single Click Action" Action - Double-Click-Delay: "; delay; "ms"
wait

[DoubleClickAction]
timer 0
#m.txt "Double Click Action"
wait

[quit]
close #m
end