Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
With the user32 variant, it seems it sets the last error to ERROR_INVALID_PARAMETER, so it is skipped in HandleChar.
dlls/user32/listbox.c | 8 +++++++- dlls/user32/tests/listbox.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 7fc724c..286a33b 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -917,6 +917,12 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa INT i; LB_ITEMDATA *item;
+ if (descr->style & LBS_NODATA) + { + SetLastError(ERROR_INVALID_PARAMETER); + return LB_ERR; + } + if (start >= descr->nb_items) start = -1; item = descr->items + start + 1; if (HAS_STRINGS(descr)) @@ -2455,7 +2461,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/user32/tests/listbox.c b/dlls/user32/tests/listbox.c index d0eb731..d13a4e3 100644 --- a/dlls/user32/tests/listbox.c +++ b/dlls/user32/tests/listbox.c @@ -2103,12 +2103,30 @@ static void test_LBS_NODATA(void) }
/* More messages that don't work with LBS_NODATA. */ + SetLastError(0xdeadbeef); + ret = SendMessageA(listbox, LB_FINDSTRING, 1, 0); + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); + SetLastError(0xdeadbeef); ret = SendMessageA(listbox, LB_FINDSTRING, 1, 42); ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 0); + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); + SetLastError(0xdeadbeef); ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 42); ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 0); + ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError()); + SetLastError(0xdeadbeef); ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 42); ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should return 0x57, got 0x%X\n", GetLastError());
DestroyWindow(listbox);