Commit 9c565342 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Implement LVM_CANCELEDITLABEL with tests.

parent e5e4d1e9
......@@ -106,7 +106,6 @@
* -- LVN_BEGINRDRAG
*
* Messages:
* -- LVM_CANCELEDITLABEL
* -- LVM_ENABLEGROUPVIEW
* -- LVM_GETBKIMAGE, LVM_SETBKIMAGE
* -- LVM_GETGROUPINFO, LVM_SETGROUPINFO
......@@ -419,6 +418,7 @@ static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *, INT, BOOL);
static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, BOOL);
static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST);
static INT LISTVIEW_HitTest(const LISTVIEW_INFO *, LPLVHITTESTINFO, BOOL, BOOL);
static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *, BOOL, BOOL);
/******** Text handling functions *************************************/
......@@ -4591,6 +4591,26 @@ static DWORD LISTVIEW_ApproximateViewRect(const LISTVIEW_INFO *infoPtr, INT nIte
return dwViewRect;
}
/***
* DESCRIPTION:
* Cancel edit label with saving item text.
*
* PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure
*
* RETURN:
* Always returns TRUE.
*/
static LRESULT LISTVIEW_CancelEditLabel(LISTVIEW_INFO *infoPtr)
{
/* handle value will be lost after LISTVIEW_EndEditLabelT */
HWND edit = infoPtr->hwndEdit;
LISTVIEW_EndEditLabelT(infoPtr, TRUE, IsWindowUnicode(infoPtr->hwndEdit));
SendMessageW(edit, WM_CLOSE, 0, 0);
return TRUE;
}
/***
* DESCRIPTION:
......@@ -10113,7 +10133,8 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case LVM_ARRANGE:
return LISTVIEW_Arrange(infoPtr, (INT)wParam);
/* case LVM_CANCELEDITLABEL: */
case LVM_CANCELEDITLABEL:
return LISTVIEW_CancelEditLabel(infoPtr);
case LVM_CREATEDRAGIMAGE:
return (LRESULT)LISTVIEW_CreateDragImage(infoPtr, (INT)wParam, (LPPOINT)lParam);
......@@ -10734,11 +10755,7 @@ static LRESULT LISTVIEW_Command(LISTVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lP
}
case EN_KILLFOCUS:
{
/* handle value will be lost after LISTVIEW_EndEditLabelT */
HWND edit = infoPtr->hwndEdit;
LISTVIEW_EndEditLabelT(infoPtr, TRUE, IsWindowUnicode(infoPtr->hwndEdit));
SendMessageW(edit, WM_CLOSE, 0, 0);
LISTVIEW_CancelEditLabel(infoPtr);
}
default:
......
......@@ -3534,6 +3534,55 @@ static void test_get_set_view(void)
DestroyWindow(hwnd);
}
static void test_canceleditlabel(void)
{
HWND hwnd, hwndedit;
DWORD ret;
CHAR buff[10];
LVITEMA itema;
static CHAR test[] = "test";
static const CHAR test1[] = "test1";
hwnd = create_listview_control(LVS_EDITLABELS);
ok(hwnd != NULL, "failed to create a listview window\n");
insert_item(hwnd, 0);
/* try without edit created */
ret = SendMessage(hwnd, LVM_CANCELEDITLABEL, 0, 0);
expect(TRUE, ret);
/* cancel without data change */
SetFocus(hwnd);
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
ok(IsWindow(hwndedit), "Expected edit control to be created\n");
ret = SendMessage(hwnd, LVM_CANCELEDITLABEL, 0, 0);
expect(TRUE, ret);
ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
/* cancel after data change */
memset(&itema, 0, sizeof(itema));
itema.pszText = test;
ret = SendMessage(hwnd, LVM_SETITEMTEXT, 0, (LPARAM)&itema);
expect(TRUE, ret);
SetFocus(hwnd);
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
ok(IsWindow(hwndedit), "Expected edit control to be created\n");
ret = SetWindowText(hwndedit, test1);
ok(ret != 0, "Expected edit text to change\n");
ret = SendMessage(hwnd, LVM_CANCELEDITLABEL, 0, 0);
expect(TRUE, ret);
ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
memset(&itema, 0, sizeof(itema));
itema.pszText = buff;
itema.cchTextMax = sizeof(buff)/sizeof(CHAR);
ret = SendMessage(hwnd, LVM_GETITEMTEXT, 0, (LPARAM)&itema);
expect(5, ret);
ok(strcmp(buff, test1) == 0, "Expected label text not to change\n");
DestroyWindow(hwnd);
}
START_TEST(listview)
{
HMODULE hComctl32;
......@@ -3598,6 +3647,7 @@ START_TEST(listview)
/* comctl32 version 6 tests start here */
test_get_set_view();
test_canceleditlabel();
unload_v6_module(ctx_cookie);
......
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