From 899a53eda508b71a5f8366f95a8c7640f0d9dc45 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 21 Nov 2009 14:37:01 +0300 Subject: [PATCH] comctl32/listview: Send LVN_ENDLABELEDIT in any case, but with null text if it's the same. --- dlls/comctl32/listview.c | 14 +++++++------- dlls/comctl32/tests/listview.c | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 40804b59b97..cd924de1d2d 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -5585,16 +5585,11 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL bSame = (lstrcmpW(dispInfo.item.pszText, tmp) == 0); textfreeT(tmp, FALSE); } - if (bSame) - { - res = TRUE; - goto cleanup; - } /* add the text from the edit in */ dispInfo.item.mask |= LVIF_TEXT; - dispInfo.item.pszText = pszText; - dispInfo.item.cchTextMax = textlenT(pszText, isW); + dispInfo.item.pszText = bSame ? NULL : pszText; + dispInfo.item.cchTextMax = bSame ? 0 : textlenT(pszText, isW); /* Do we need to update the Item Text */ if (!notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW)) @@ -5608,6 +5603,11 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL goto cleanup; } if (!pszText) return TRUE; + if (bSame) + { + res = TRUE; + goto cleanup; + } if (!(infoPtr->dwStyle & LVS_OWNERDATA)) { diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 99c25da8c7f..7bf2b03087b 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -272,7 +272,7 @@ static const struct message lvs_ex_transparentbkgnd_seq[] = { }; static const struct message edit_end_nochange[] = { - { WM_NOTIFY, sent|id, 0, 0, LVN_ENDLABELEDITA }, /* todo */ + { WM_NOTIFY, sent|id, 0, 0, LVN_ENDLABELEDITA }, { WM_NOTIFY, sent|id, 0, 0, NM_CUSTOMDRAW }, /* todo */ { WM_NOTIFY, sent|id, 0, 0, NM_SETFOCUS }, { 0 } @@ -321,8 +321,12 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP return blockEdit; case LVN_ENDLABELEDIT: + { /* always accept new item text */ + NMLVDISPINFO *di = (NMLVDISPINFO*)lParam; + trace("LVN_ENDLABELEDIT: text=%s\n", di->item.pszText); return TRUE; + } case LVN_BEGINSCROLL: case LVN_ENDSCROLL: { @@ -3426,9 +3430,24 @@ static void test_editbox(void) r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item); expect(lstrlen(item.pszText), r); ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n"); + ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n"); /* end edit without saving */ + SetFocus(hwnd); + hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0); + flush_sequences(sequences, NUM_MSG_SEQUENCES); r = SendMessage(hwndedit, WM_KEYDOWN, VK_ESCAPE, 0); expect(0, r); + ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange, + "edit box - end edit, no change, escape", TRUE); + /* end edit with saving */ + SetFocus(hwnd); + hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0); + flush_sequences(sequences, NUM_MSG_SEQUENCES); + r = SendMessage(hwndedit, WM_KEYDOWN, VK_RETURN, 0); + expect(0, r); + ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange, + "edit box - end edit, no change, return", TRUE); + memset(&item, 0, sizeof(item)); item.pszText = buffer; item.cchTextMax = 10;