comctl32/listview: Handle EN_KILLFOCUS in WM_COMMAND message handler.
This commit is contained in:
parent
3ebe2ebb0d
commit
b13cd52b04
@ -33,7 +33,6 @@
|
|||||||
* TODO:
|
* TODO:
|
||||||
*
|
*
|
||||||
* Default Message Processing
|
* Default Message Processing
|
||||||
* -- EN_KILLFOCUS should be handled in WM_COMMAND
|
|
||||||
* -- WM_CREATE: create the icon and small icon image lists at this point only if
|
* -- WM_CREATE: create the icon and small icon image lists at this point only if
|
||||||
* the LVS_SHAREIMAGELISTS style is not specified.
|
* the LVS_SHAREIMAGELISTS style is not specified.
|
||||||
* -- WM_WINDOWPOSCHANGED: arrange the list items if the current view is icon
|
* -- WM_WINDOWPOSCHANGED: arrange the list items if the current view is icon
|
||||||
@ -412,7 +411,7 @@ static INT LISTVIEW_GetLabelWidth(const LISTVIEW_INFO *, INT);
|
|||||||
static void LISTVIEW_GetOrigin(const LISTVIEW_INFO *, LPPOINT);
|
static void LISTVIEW_GetOrigin(const LISTVIEW_INFO *, LPPOINT);
|
||||||
static BOOL LISTVIEW_GetViewRect(const LISTVIEW_INFO *, LPRECT);
|
static BOOL LISTVIEW_GetViewRect(const LISTVIEW_INFO *, LPRECT);
|
||||||
static void LISTVIEW_UpdateSize(LISTVIEW_INFO *);
|
static void LISTVIEW_UpdateSize(LISTVIEW_INFO *);
|
||||||
static LRESULT LISTVIEW_Command(const LISTVIEW_INFO *, WPARAM, LPARAM);
|
static LRESULT LISTVIEW_Command(LISTVIEW_INFO *, WPARAM, LPARAM);
|
||||||
static INT LISTVIEW_GetStringWidthT(const LISTVIEW_INFO *, LPCWSTR, BOOL);
|
static INT LISTVIEW_GetStringWidthT(const LISTVIEW_INFO *, LPCWSTR, BOOL);
|
||||||
static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT, BOOL);
|
static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT, BOOL);
|
||||||
static UINT LISTVIEW_GetItemState(const LISTVIEW_INFO *, INT, UINT);
|
static UINT LISTVIEW_GetItemState(const LISTVIEW_INFO *, INT, UINT);
|
||||||
@ -4920,30 +4919,51 @@ static BOOL LISTVIEW_DeleteItem(LISTVIEW_INFO *infoPtr, INT nItem)
|
|||||||
*
|
*
|
||||||
* PARAMETER(S):
|
* PARAMETER(S):
|
||||||
* [I] infoPtr : valid pointer to the listview structure
|
* [I] infoPtr : valid pointer to the listview structure
|
||||||
* [I] pszText : modified text
|
* [I] storeText : store edit box text as item text
|
||||||
* [I] isW : TRUE if psxText is Unicode, FALSE if it's ANSI
|
* [I] isW : TRUE if psxText is Unicode, FALSE if it's ANSI
|
||||||
*
|
*
|
||||||
* RETURN:
|
* RETURN:
|
||||||
* SUCCESS : TRUE
|
* SUCCESS : TRUE
|
||||||
* FAILURE : FALSE
|
* FAILURE : FALSE
|
||||||
*/
|
*/
|
||||||
static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, LPWSTR pszText, BOOL isW)
|
static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL isW)
|
||||||
{
|
{
|
||||||
HWND hwndSelf = infoPtr->hwndSelf;
|
HWND hwndSelf = infoPtr->hwndSelf;
|
||||||
NMLVDISPINFOW dispInfo;
|
NMLVDISPINFOW dispInfo;
|
||||||
INT editedItem = infoPtr->nEditLabelItem;
|
INT editedItem = infoPtr->nEditLabelItem;
|
||||||
BOOL bSame;
|
BOOL bSame;
|
||||||
|
WCHAR *pszText = NULL;
|
||||||
|
BOOL res;
|
||||||
|
|
||||||
|
if (storeText)
|
||||||
|
{
|
||||||
|
DWORD len = isW ? GetWindowTextLengthW(infoPtr->hwndEdit) : GetWindowTextLengthA(infoPtr->hwndEdit);
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
if ((pszText = Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))))
|
||||||
|
{
|
||||||
|
if (isW) GetWindowTextW(infoPtr->hwndEdit, pszText, len+1);
|
||||||
|
else GetWindowTextA(infoPtr->hwndEdit, (CHAR*)pszText, len+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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->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;
|
||||||
dispInfo.item.iSubItem = 0;
|
dispInfo.item.iSubItem = 0;
|
||||||
dispInfo.item.stateMask = ~0;
|
dispInfo.item.stateMask = ~0;
|
||||||
if (!LISTVIEW_GetItemW(infoPtr, &dispInfo.item)) return FALSE;
|
if (!LISTVIEW_GetItemW(infoPtr, &dispInfo.item))
|
||||||
|
{
|
||||||
|
res = FALSE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (isW)
|
if (isW)
|
||||||
bSame = (lstrcmpW(dispInfo.item.pszText, pszText) == 0);
|
bSame = (lstrcmpW(dispInfo.item.pszText, pszText) == 0);
|
||||||
@ -4953,7 +4973,11 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, LPWSTR pszText, BOOL
|
|||||||
bSame = (lstrcmpW(dispInfo.item.pszText, tmp) == 0);
|
bSame = (lstrcmpW(dispInfo.item.pszText, tmp) == 0);
|
||||||
textfreeT(tmp, FALSE);
|
textfreeT(tmp, FALSE);
|
||||||
}
|
}
|
||||||
if (bSame) return TRUE;
|
if (bSame)
|
||||||
|
{
|
||||||
|
res = TRUE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* add the text from the edit in */
|
/* add the text from the edit in */
|
||||||
dispInfo.item.mask |= LVIF_TEXT;
|
dispInfo.item.mask |= LVIF_TEXT;
|
||||||
@ -4961,9 +4985,16 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, LPWSTR pszText, BOOL
|
|||||||
dispInfo.item.cchTextMax = textlenT(pszText, isW);
|
dispInfo.item.cchTextMax = textlenT(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)) return FALSE;
|
if (!notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW))
|
||||||
|
{
|
||||||
|
res = FALSE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (!IsWindow(hwndSelf))
|
if (!IsWindow(hwndSelf))
|
||||||
return FALSE;
|
{
|
||||||
|
res = FALSE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (!pszText) return TRUE;
|
if (!pszText) return TRUE;
|
||||||
|
|
||||||
if (!(infoPtr->dwStyle & LVS_OWNERDATA))
|
if (!(infoPtr->dwStyle & LVS_OWNERDATA))
|
||||||
@ -4973,7 +5004,8 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, LPWSTR pszText, BOOL
|
|||||||
if (lpItem && lpItem->hdr.pszText == LPSTR_TEXTCALLBACKW)
|
if (lpItem && lpItem->hdr.pszText == LPSTR_TEXTCALLBACKW)
|
||||||
{
|
{
|
||||||
LISTVIEW_InvalidateItem(infoPtr, editedItem);
|
LISTVIEW_InvalidateItem(infoPtr, editedItem);
|
||||||
return TRUE;
|
res = TRUE;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4983,7 +5015,12 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, LPWSTR pszText, BOOL
|
|||||||
dispInfo.item.iSubItem = 0;
|
dispInfo.item.iSubItem = 0;
|
||||||
dispInfo.item.pszText = pszText;
|
dispInfo.item.pszText = pszText;
|
||||||
dispInfo.item.cchTextMax = textlenT(pszText, isW);
|
dispInfo.item.cchTextMax = textlenT(pszText, isW);
|
||||||
return LISTVIEW_SetItemT(infoPtr, &dispInfo.item, isW);
|
res = LISTVIEW_SetItemT(infoPtr, &dispInfo.item, isW);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
Free(pszText);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -10454,7 +10491,7 @@ void LISTVIEW_Unregister(void)
|
|||||||
* RETURN:
|
* RETURN:
|
||||||
* Zero.
|
* Zero.
|
||||||
*/
|
*/
|
||||||
static LRESULT LISTVIEW_Command(const LISTVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
static LRESULT LISTVIEW_Command(LISTVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (HIWORD(wParam))
|
switch (HIWORD(wParam))
|
||||||
{
|
{
|
||||||
@ -10504,6 +10541,14 @@ static LRESULT LISTVIEW_Command(const LISTVIEW_INFO *infoPtr, WPARAM wParam, LPA
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return SendMessageW (infoPtr->hwndNotify, WM_COMMAND, wParam, lParam);
|
return SendMessageW (infoPtr->hwndNotify, WM_COMMAND, wParam, lParam);
|
||||||
@ -10530,7 +10575,7 @@ static LRESULT LISTVIEW_Command(const LISTVIEW_INFO *infoPtr, WPARAM wParam, LPA
|
|||||||
static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL isW)
|
static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL isW)
|
||||||
{
|
{
|
||||||
LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongPtrW(GetParent(hwnd), 0);
|
LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongPtrW(GetParent(hwnd), 0);
|
||||||
BOOL cancel = FALSE;
|
BOOL save = TRUE;
|
||||||
|
|
||||||
TRACE("(hwnd=%p, uMsg=%x, wParam=%lx, lParam=%lx, isW=%d)\n",
|
TRACE("(hwnd=%p, uMsg=%x, wParam=%lx, lParam=%lx, isW=%d)\n",
|
||||||
hwnd, uMsg, wParam, lParam, isW);
|
hwnd, uMsg, wParam, lParam, isW);
|
||||||
@ -10540,9 +10585,6 @@ static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||||||
case WM_GETDLGCODE:
|
case WM_GETDLGCODE:
|
||||||
return DLGC_WANTARROWS | DLGC_WANTALLKEYS;
|
return DLGC_WANTARROWS | DLGC_WANTALLKEYS;
|
||||||
|
|
||||||
case WM_KILLFOCUS:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
WNDPROC editProc = infoPtr->EditWndProc;
|
WNDPROC editProc = infoPtr->EditWndProc;
|
||||||
@ -10554,7 +10596,7 @@ static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
if (VK_ESCAPE == (INT)wParam)
|
if (VK_ESCAPE == (INT)wParam)
|
||||||
{
|
{
|
||||||
cancel = TRUE;
|
save = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (VK_RETURN == (INT)wParam)
|
else if (VK_RETURN == (INT)wParam)
|
||||||
@ -10566,27 +10608,7 @@ static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||||||
|
|
||||||
/* kill the edit */
|
/* kill the edit */
|
||||||
if (infoPtr->hwndEdit)
|
if (infoPtr->hwndEdit)
|
||||||
{
|
LISTVIEW_EndEditLabelT(infoPtr, save, isW);
|
||||||
LPWSTR buffer = NULL;
|
|
||||||
|
|
||||||
infoPtr->hwndEdit = 0;
|
|
||||||
if (!cancel)
|
|
||||||
{
|
|
||||||
DWORD len = isW ? GetWindowTextLengthW(hwnd) : GetWindowTextLengthA(hwnd);
|
|
||||||
|
|
||||||
if (len)
|
|
||||||
{
|
|
||||||
if ( (buffer = Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))) )
|
|
||||||
{
|
|
||||||
if (isW) GetWindowTextW(hwnd, buffer, len+1);
|
|
||||||
else GetWindowTextA(hwnd, (CHAR*)buffer, len+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LISTVIEW_EndEditLabelT(infoPtr, buffer, isW);
|
|
||||||
|
|
||||||
Free(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
SendMessageW(hwnd, WM_CLOSE, 0, 0);
|
SendMessageW(hwnd, WM_CLOSE, 0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2915,7 +2915,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(strlen(item.pszText), r);
|
expect(strlen(item.pszText), r);
|
||||||
todo_wine ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
|
ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
|
||||||
/* end edit without saving */
|
/* end edit without saving */
|
||||||
r = SendMessage(hwndedit, WM_KEYDOWN, VK_ESCAPE, 0);
|
r = SendMessage(hwndedit, WM_KEYDOWN, VK_ESCAPE, 0);
|
||||||
expect(0, r);
|
expect(0, r);
|
||||||
@ -2926,7 +2926,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(strlen(item.pszText), r);
|
expect(strlen(item.pszText), r);
|
||||||
todo_wine ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
|
ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
|
||||||
|
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user