Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/comctl32/listbox.c | 5 ++++- dlls/comctl32/tests/listbox.c | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index ab01430..7747c33 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -919,6 +919,9 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa } else { + if (descr->style & LBS_NODATA) + return LB_ERR; + if (exact && (descr->style & LBS_SORT)) /* If sorted, use a WM_COMPAREITEM binary search */ return LISTBOX_FindStringPos( descr, str, TRUE ); @@ -2450,7 +2453,7 @@ static LRESULT LISTBOX_HandleChar( LB_DESCR *descr, WCHAR charW ) (LPARAM)descr->self ); if (caret == -2) return 0; } - if (caret == -1) + if (caret == -1 && !(descr->style & LBS_NODATA)) caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE); if (caret != -1) { diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index 87b3ec0..6a3c345 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -1885,10 +1885,16 @@ static void test_nodata( void ) /* test more invalid messages with LBS_NODATA */ ret = SendMessageA(listbox, LB_FINDSTRING, 1, 42); ok(ret == LB_ERR, "got %d\n", ret); + ret = SendMessageA(listbox, LB_FINDSTRING, 1, 0); + ok(ret == LB_ERR, "got %d\n", ret); ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 42); ok(ret == LB_ERR, "got %d\n", ret); + ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 0); + ok(ret == LB_ERR, "got %d\n", ret); ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 42); ok(ret == LB_ERR, "got %d\n", ret); + ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 0); + ok(ret == LB_ERR, "got %d\n", ret);
DestroyWindow(listbox); }