Commit dfb57a16 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

user32/listbox: Make LBS_NODATA listboxes error on any attempt to find a value.

parent d30aadd3
...@@ -917,6 +917,12 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa ...@@ -917,6 +917,12 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa
INT i; INT i;
LB_ITEMDATA *item; LB_ITEMDATA *item;
if (descr->style & LBS_NODATA)
{
SetLastError(ERROR_INVALID_PARAMETER);
return LB_ERR;
}
if (start >= descr->nb_items) start = -1; if (start >= descr->nb_items) start = -1;
item = descr->items + start + 1; item = descr->items + start + 1;
if (HAS_STRINGS(descr)) if (HAS_STRINGS(descr))
...@@ -2455,7 +2461,7 @@ static LRESULT LISTBOX_HandleChar( LB_DESCR *descr, WCHAR charW ) ...@@ -2455,7 +2461,7 @@ static LRESULT LISTBOX_HandleChar( LB_DESCR *descr, WCHAR charW )
(LPARAM)descr->self ); (LPARAM)descr->self );
if (caret == -2) return 0; if (caret == -2) return 0;
} }
if (caret == -1) if (caret == -1 && !(descr->style & LBS_NODATA))
caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE); caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE);
if (caret != -1) if (caret != -1)
{ {
......
...@@ -2103,12 +2103,30 @@ static void test_LBS_NODATA(void) ...@@ -2103,12 +2103,30 @@ static void test_LBS_NODATA(void)
} }
/* More messages that don't work with LBS_NODATA. */ /* 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); ret = SendMessageA(listbox, LB_FINDSTRING, 1, 42);
ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 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); ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 42);
ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 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); ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 42);
ok(ret == LB_ERR, "Unexpected return value %d.\n", ret); 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); DestroyWindow(listbox);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment