Commit 34d86a2d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Make edit box handle available from LVN_ENDLABELEDIT notification.

parent 5f12a642
...@@ -5662,7 +5662,7 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL ...@@ -5662,7 +5662,7 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL
WCHAR szDispText[DISP_TEXT_SIZE] = { 0 }; WCHAR szDispText[DISP_TEXT_SIZE] = { 0 };
NMLVDISPINFOW dispInfo; NMLVDISPINFOW dispInfo;
INT editedItem = infoPtr->nEditLabelItem; INT editedItem = infoPtr->nEditLabelItem;
BOOL bSame; BOOL same;
WCHAR *pszText = NULL; WCHAR *pszText = NULL;
BOOL res; BOOL res;
...@@ -5682,9 +5682,6 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL ...@@ -5682,9 +5682,6 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL
TRACE("(pszText=%s, isW=%d)\n", debugtext_t(pszText, isW), isW); TRACE("(pszText=%s, isW=%d)\n", debugtext_t(pszText, isW), isW);
infoPtr->nEditLabelItem = -1;
infoPtr->hwndEdit = 0;
ZeroMemory(&dispInfo, sizeof(dispInfo)); ZeroMemory(&dispInfo, sizeof(dispInfo));
dispInfo.item.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT; dispInfo.item.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;
dispInfo.item.iItem = editedItem; dispInfo.item.iItem = editedItem;
...@@ -5699,32 +5696,34 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL ...@@ -5699,32 +5696,34 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL
} }
if (isW) if (isW)
bSame = (lstrcmpW(dispInfo.item.pszText, pszText) == 0); same = (lstrcmpW(dispInfo.item.pszText, pszText) == 0);
else else
{ {
LPWSTR tmp = textdupTtoW(pszText, FALSE); LPWSTR tmp = textdupTtoW(pszText, FALSE);
bSame = (lstrcmpW(dispInfo.item.pszText, tmp) == 0); same = (lstrcmpW(dispInfo.item.pszText, tmp) == 0);
textfreeT(tmp, FALSE); textfreeT(tmp, FALSE);
} }
/* add the text from the edit in */ /* add the text from the edit in */
dispInfo.item.mask |= LVIF_TEXT; dispInfo.item.mask |= LVIF_TEXT;
dispInfo.item.pszText = bSame ? NULL : pszText; dispInfo.item.pszText = same ? NULL : pszText;
dispInfo.item.cchTextMax = bSame ? 0 : textlenT(pszText, isW); dispInfo.item.cchTextMax = textlenT(dispInfo.item.pszText, isW);
/* Do we need to update the Item Text */ /* Do we need to update the Item Text */
if (!notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW)) res = notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW);
{
res = FALSE; infoPtr->nEditLabelItem = -1;
goto cleanup; infoPtr->hwndEdit = 0;
}
if (!res) goto cleanup;
if (!IsWindow(hwndSelf)) if (!IsWindow(hwndSelf))
{ {
res = FALSE; res = FALSE;
goto cleanup; goto cleanup;
} }
if (!pszText) return TRUE; if (!pszText) return TRUE;
if (bSame) if (same)
{ {
res = TRUE; res = TRUE;
goto cleanup; goto cleanup;
......
...@@ -61,6 +61,8 @@ static BOOL g_is_below_5; ...@@ -61,6 +61,8 @@ static BOOL g_is_below_5;
static LVITEMA g_itema; static LVITEMA g_itema;
/* alter notification code A->W */ /* alter notification code A->W */
static BOOL g_disp_A_to_W; static BOOL g_disp_A_to_W;
/* dispinfo data sent with LVN_LVN_ENDLABELEDIT */
static NMLVDISPINFO g_editbox_disp_info;
static HWND subclass_editbox(HWND hwndListview); static HWND subclass_editbox(HWND hwndListview);
...@@ -358,9 +360,17 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP ...@@ -358,9 +360,17 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP
} }
case LVN_ENDLABELEDIT: case LVN_ENDLABELEDIT:
{ {
HWND edit;
/* always accept new item text */ /* always accept new item text */
NMLVDISPINFO *di = (NMLVDISPINFO*)lParam; NMLVDISPINFO *di = (NMLVDISPINFO*)lParam;
g_editbox_disp_info = *di;
trace("LVN_ENDLABELEDIT: text=%s\n", di->item.pszText); trace("LVN_ENDLABELEDIT: text=%s\n", di->item.pszText);
/* edit control still available from this notification */
edit = (HWND)SendMessageA(((NMHDR*)lParam)->hwndFrom, LVM_GETEDITCONTROL, 0, 0);
ok(IsWindow(edit), "expected valid edit control handle\n");
return TRUE; return TRUE;
} }
case LVN_BEGINSCROLL: case LVN_BEGINSCROLL:
...@@ -3611,6 +3621,7 @@ static void test_editbox(void) ...@@ -3611,6 +3621,7 @@ static void test_editbox(void)
{ {
static CHAR testitemA[] = "testitem"; static CHAR testitemA[] = "testitem";
static CHAR testitem1A[] = "testitem_quitelongname"; static CHAR testitem1A[] = "testitem_quitelongname";
static CHAR testitem2A[] = "testITEM_quitelongname";
static CHAR buffer[25]; static CHAR buffer[25];
HWND hwnd, hwndedit, hwndedit2, header; HWND hwnd, hwndedit, hwndedit2, header;
LVITEMA item; LVITEMA item;
...@@ -3707,8 +3718,11 @@ static void test_editbox(void) ...@@ -3707,8 +3718,11 @@ static void test_editbox(void)
/* modify edit and notify control that it lost focus */ /* modify edit and notify control that it lost focus */
r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A); r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
expect(TRUE, r); expect(TRUE, r);
g_editbox_disp_info.item.pszText = NULL;
r = SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit); r = SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
expect(0, r); expect(0, r);
ok(g_editbox_disp_info.item.pszText != NULL, "expected notification with not null text\n");
memset(&item, 0, sizeof(item)); memset(&item, 0, sizeof(item));
item.pszText = buffer; item.pszText = buffer;
item.cchTextMax = sizeof(buffer); item.cchTextMax = sizeof(buffer);
...@@ -3718,6 +3732,29 @@ static void test_editbox(void) ...@@ -3718,6 +3732,29 @@ static void test_editbox(void)
expect(lstrlen(item.pszText), r); expect(lstrlen(item.pszText), r);
ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n"); ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n"); ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n");
/* change item name to differ in casing only */
SetFocus(hwnd);
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
/* modify edit and notify control that it lost focus */
r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem2A);
expect(TRUE, r);
g_editbox_disp_info.item.pszText = NULL;
r = SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
expect(0, r);
ok(g_editbox_disp_info.item.pszText != NULL, "got %p\n", g_editbox_disp_info.item.pszText);
memset(&item, 0, sizeof(item));
item.pszText = buffer;
item.cchTextMax = sizeof(buffer);
item.iItem = 0;
item.iSubItem = 0;
r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
expect(lstrlen(item.pszText), r);
ok(strcmp(buffer, testitem2A) == 0, "got %s, expected %s\n", buffer, testitem2A);
ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n");
/* end edit without saving */ /* end edit without saving */
SetFocus(hwnd); SetFocus(hwnd);
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0); hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
...@@ -3742,7 +3779,7 @@ static void test_editbox(void) ...@@ -3742,7 +3779,7 @@ static void test_editbox(void)
item.iSubItem = 0; item.iSubItem = 0;
r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item); r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
expect(lstrlen(item.pszText), r); expect(lstrlen(item.pszText), r);
ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n"); ok(strcmp(buffer, testitem2A) == 0, "Expected item text to change\n");
/* LVM_EDITLABEL with -1 destroys current edit */ /* LVM_EDITLABEL with -1 destroys current edit */
hwndedit = (HWND)SendMessage(hwnd, LVM_GETEDITCONTROL, 0, 0); hwndedit = (HWND)SendMessage(hwnd, LVM_GETEDITCONTROL, 0, 0);
...@@ -3786,7 +3823,7 @@ static void test_editbox(void) ...@@ -3786,7 +3823,7 @@ static void test_editbox(void)
ok_sequence(sequences, EDITBOX_SEQ_INDEX, editbox_create_pos, ok_sequence(sequences, EDITBOX_SEQ_INDEX, editbox_create_pos,
"edit box create - sizing", FALSE); "edit box create - sizing", FALSE);
/* WM_COMMAND with EN_KILLFOCUS isn't forwared to parent */ /* WM_COMMAND with EN_KILLFOCUS isn't forwarded to parent */
SetFocus(hwnd); SetFocus(hwnd);
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0); hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
ok(IsWindow(hwndedit), "Expected Edit window to be created\n"); ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
......
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