Search code examples
windowswinapilistboxuser32

Listbox: WM_CHAR time interval for searching items


The Microsoft documentation of WM_CHAR for the listbox control states this (emphasis of short interval is mine):

WM_CHAR
Moves selection to the first item that begins with the character that the user typed. If the list box has the LBS_OWNERDRAW style, no action occurs. Multiple characters that are typed within a short interval are treated as a group, and the first item that begins with that series of characters is selected.

They mention a short interval.

Does anybody know if the duration of this interval can be obtained somehow?

I have an onwer draw listbox where the bahaviour described above does not occur (which is the normal documented behaviour), and I'm emulating this myself using an interval of 1.5 seconds (which seems to be more or less the duration of the short interval).

Everything works fine, but rather than using a hard coded duration of 1.5 seconds, I'd like to retrieve this duration from somewhere (registry, some API I'm not aware of, ...) so the interval is the one used by the default behaviour of a list box.


Solution

  • in my test i found that ListBox use time returned by GetDoubleClickTime() and multiple it on 4.

    so interval = 4 * GetDoubleClickTime() or GetDoubleClickTime() << 2.

    enter image description here

    we can test this by change double-click time with SetDoubleClickTime function for example

    UINT t = GetDoubleClickTime();
    SetDoubleClickTime(4000);
    test();
    SetDoubleClickTime(t);
    

    or by hook and modify GetDoubleClickTime return value or change asm code under debugger (for not change even temporary global windows settings). anyway change return value from GetDoubleClickTime have visible effect for ListBox behavior