Commit fe966335 authored by Lei Zhang's avatar Lei Zhang Committed by Alexandre Julliard

comctl32: Implement listview checkbox toggle.

parent 778c04db
......@@ -1353,6 +1353,19 @@ static inline BOOL is_autoarrange(const LISTVIEW_INFO *infoPtr)
(uView == LVS_ICON || uView == LVS_SMALLICON);
}
static void toggle_checkbox_state(LISTVIEW_INFO *infoPtr, INT nItem)
{
DWORD state = STATEIMAGEINDEX(LISTVIEW_GetItemState(infoPtr, nItem, LVIS_STATEIMAGEMASK));
if(state == 1 || state == 2)
{
LVITEMW lvitem;
state ^= 3;
lvitem.state = INDEXTOSTATEIMAGEMASK(state);
lvitem.stateMask = LVIS_STATEIMAGEMASK;
LISTVIEW_SetItemState(infoPtr, nItem, &lvitem);
}
}
/******** Internal API functions ************************************/
static inline COLUMN_INFO * LISTVIEW_GetColumnInfo(const LISTVIEW_INFO *infoPtr, INT nSubItem)
......@@ -8283,6 +8296,8 @@ static LRESULT LISTVIEW_KeyDown(LISTVIEW_INFO *infoPtr, INT nVirtualKey, LONG lK
{
case VK_SPACE:
nItem = infoPtr->nFocusedItem;
if (infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES)
toggle_checkbox_state(infoPtr, infoPtr->nFocusedItem);
break;
case VK_RETURN:
......@@ -8475,15 +8490,7 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, IN
{
if ((infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) && (lvHitTestInfo.flags & LVHT_ONITEMSTATEICON))
{
DWORD state = STATEIMAGEINDEX(LISTVIEW_GetItemState(infoPtr, nItem, LVIS_STATEIMAGEMASK));
if(state == 1 || state == 2)
{
LVITEMW lvitem;
state ^= 3;
lvitem.state = INDEXTOSTATEIMAGEMASK(state);
lvitem.stateMask = LVIS_STATEIMAGEMASK;
LISTVIEW_SetItemState(infoPtr, nItem, &lvitem);
}
toggle_checkbox_state(infoPtr, nItem);
return 0;
}
......
......@@ -564,7 +564,7 @@ static void test_checkboxes(void)
item.mask = LVIF_STATE;
item.stateMask = 0xffff;
r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
todo_wine ok(item.state == 0x2aab, "state %x\n", item.state);
ok(item.state == 0x2aab, "state %x\n", item.state);
r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);
expect(0, r);
......
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