Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57746 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
-- v2: comctl32/listview: Use correct LVN_ODFINDITEM notification. comctl32/tests: Add a test for LVM_FINDITEM with LVS_OWNERDATA.
From: Nikolay Sivov nsivov@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57746 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tests/listview.c | 66 ++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 1a212e5d0ad..7b4a495f11e 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -5546,10 +5546,24 @@ todo_wine {
}
-static void test_finditem(void) +static const struct message finditem_ownerdata_parent_seq[] = { + { WM_NOTIFY, sent|id|wparam, 0, 0, LVN_ODFINDITEMA }, + { 0 } +}; + +static const struct message finditem_ownerdata_parent_seq2[] = +{ + { WM_NOTIFY, sent|id|wparam, 0, 0, LVN_ODFINDITEMW }, + { 0 } +}; + +static void test_LVM_FINDITEM(void) +{ + LVFINDINFOW fiW; LVFINDINFOA fi; static char f[5]; + WCHAR strW[5]; HWND hwnd; INT r;
@@ -5557,6 +5571,7 @@ static void test_finditem(void) insert_item(hwnd, 0);
memset(&fi, 0, sizeof(fi)); + memset(&fiW, 0, sizeof(fiW));
/* full string search, inserted text was "foo" */ strcpy(f, "foo"); @@ -5642,6 +5657,51 @@ static void test_finditem(void) ok(!r, "Unexpected item index %d.\n", r);
DestroyWindow(hwnd); + + /* LVS_OWNERDATA */ + hwnd = create_listview_control(LVS_REPORT | LVS_OWNERDATA); + ok(!!hwnd, "Failed to create alistview window.\n"); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + strcpy(f, "foo"); + fi.flags = LVFI_STRING; + fi.psz = f; + r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi); + ok(!r, "Unexpected return value %d.\n", r); + ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq, "LVM_FINDITEMA owner data test", TRUE); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + wcscpy(strW, L"foo"); + fiW.flags = LVFI_STRING; + fiW.psz = strW; + r = SendMessageA(hwnd, LVM_FINDITEMW, -1, (LPARAM)&fiW); + ok(!r, "Unexpected return value %d.\n", r); + ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq, "LVM_FINDITEMW owner data test", TRUE); + + /* Force Unicode notifications */ + notifyFormat = NFR_UNICODE; + r = SendMessageA(hwnd, WM_NOTIFYFORMAT, 0, NF_REQUERY); + ok(r == NFR_UNICODE, "Unexpected return value %d.\n", r); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + strcpy(f, "foo"); + fi.flags = LVFI_STRING; + fi.psz = f; + r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi); + ok(!r, "Unexpected return value %d.\n", r); + ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq2, "LVM_FINDITEMA(W) owner data test", FALSE); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + wcscpy(strW, L"foo"); + fiW.flags = LVFI_STRING; + fiW.psz = strW; + r = SendMessageA(hwnd, LVM_FINDITEMW, -1, (LPARAM)&fiW); + ok(!r, "Unexpected return value %d.\n", r); + ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq2, "LVM_FINDITEMW(W) owner data test", FALSE); + + notifyFormat = -1; + + DestroyWindow(hwnd); }
static void test_LVS_EX_HEADERINALLVIEWS(void) @@ -7350,7 +7410,7 @@ START_TEST(listview) test_getitemspacing(); test_getcolumnwidth(); test_approximate_viewrect(); - test_finditem(); + test_LVM_FINDITEM(); test_hover(); test_destroynotify(); test_createdragimage(); @@ -7406,7 +7466,7 @@ START_TEST(listview) test_norecompute(); test_nosortheader(); test_indentation(); - test_finditem(); + test_LVM_FINDITEM(); test_hover(); test_destroynotify(); test_createdragimage();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/listview.c | 32 ++++++++++++++++++++++++++++++-- dlls/comctl32/tests/listview.c | 4 ++-- 2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 1a0c919e962..0404b6b70d4 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -1023,6 +1023,34 @@ static BOOL notify_dispinfoT(const LISTVIEW_INFO *infoPtr, UINT code, LPNMLVDISP return ret; }
+static int notify_odfinditem(const LISTVIEW_INFO *infoPtr, NMLVFINDITEMW *nmlv) +{ + NMLVFINDITEMA nmlva; + char *str = NULL; + int len, ret; + + if (infoPtr->notifyFormat == NFR_UNICODE) + return notify_hdr(infoPtr, LVN_ODFINDITEMW, &nmlv->hdr); + + /* A/W layout is the same, the only difference is string encoding. */ + memcpy(&nmlva, nmlv, sizeof(nmlva)); + nmlva.lvfi.psz = NULL; + + if (nmlv->lvfi.psz) + { + len = WideCharToMultiByte(CP_ACP, 0, nmlv->lvfi.psz, -1, NULL, 0, NULL, NULL); + str = Alloc(len); + if (!str) return 0; + WideCharToMultiByte(CP_ACP, 0, nmlv->lvfi.psz, -1, str, len, NULL, NULL); + nmlva.lvfi.psz = str; + } + + ret = notify_hdr(infoPtr, LVN_ODFINDITEMA, &nmlva.hdr); + Free(str); + + return ret; +} + static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, const LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *rcBounds, const LVITEMW *lplvItem) { @@ -1917,7 +1945,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L
infoPtr->szSearchParam[infoPtr->nSearchParamLength] = 0;
- nItem = notify_hdr(infoPtr, LVN_ODFINDITEMW, (LPNMHDR)&nmlv.hdr); + nItem = notify_odfinditem(infoPtr, &nmlv); } else { @@ -6301,7 +6329,7 @@ static INT LISTVIEW_FindItemW(const LISTVIEW_INFO *infoPtr, INT nStart,
nmlv.iStart = nStart; nmlv.lvfi = *lpFindInfo; - return notify_hdr(infoPtr, LVN_ODFINDITEMW, (LPNMHDR)&nmlv.hdr); + return notify_odfinditem(infoPtr, &nmlv); }
if (!lpFindInfo || nItem < 0) return -1; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 7b4a495f11e..1409c1491eb 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -5668,7 +5668,7 @@ static void test_LVM_FINDITEM(void) fi.psz = f; r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi); ok(!r, "Unexpected return value %d.\n", r); - ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq, "LVM_FINDITEMA owner data test", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq, "LVM_FINDITEMA owner data test", FALSE);
flush_sequences(sequences, NUM_MSG_SEQUENCES); wcscpy(strW, L"foo"); @@ -5676,7 +5676,7 @@ static void test_LVM_FINDITEM(void) fiW.psz = strW; r = SendMessageA(hwnd, LVM_FINDITEMW, -1, (LPARAM)&fiW); ok(!r, "Unexpected return value %d.\n", r); - ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq, "LVM_FINDITEMW owner data test", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, finditem_ownerdata_parent_seq, "LVM_FINDITEMW owner data test", FALSE);
/* Force Unicode notifications */ notifyFormat = NFR_UNICODE;
This merge request was approved by Zhiyi Zhang.