comctl32/tab: Fix TCM_SETCURSEL on negative indices.
This commit is contained in:
parent
8c2b4bfe48
commit
0e73e478ff
|
@ -252,22 +252,29 @@ static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem)
|
|||
|
||||
TRACE("(%p %d)\n", infoPtr, iItem);
|
||||
|
||||
if (iItem < 0)
|
||||
infoPtr->iSelected = -1;
|
||||
else if (iItem >= infoPtr->uNumItem)
|
||||
if (iItem >= (INT)infoPtr->uNumItem)
|
||||
return -1;
|
||||
else {
|
||||
|
||||
if (prevItem != iItem) {
|
||||
if (prevItem != -1)
|
||||
TAB_GetItem(infoPtr, prevItem)->dwState &= ~TCIS_BUTTONPRESSED;
|
||||
TAB_GetItem(infoPtr, iItem)->dwState |= TCIS_BUTTONPRESSED;
|
||||
|
||||
if (iItem >= 0)
|
||||
{
|
||||
TAB_GetItem(infoPtr, iItem)->dwState |= TCIS_BUTTONPRESSED;
|
||||
infoPtr->iSelected = iItem;
|
||||
infoPtr->uFocus = iItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
infoPtr->iSelected = -1;
|
||||
infoPtr->uFocus = -1;
|
||||
}
|
||||
|
||||
TAB_EnsureSelectionVisible(infoPtr);
|
||||
TAB_InvalidateTabArea(infoPtr);
|
||||
}
|
||||
}
|
||||
|
||||
return prevItem;
|
||||
}
|
||||
|
||||
|
|
|
@ -746,6 +746,24 @@ static void test_cursel(void)
|
|||
ok (tcItem.dwState & TCIS_BUTTONPRESSED || broken(tcItem.dwState == 0), /* older comctl32 */
|
||||
"Selected item should have TCIS_BUTTONPRESSED\n");
|
||||
|
||||
/* now deselect all and check previously selected item state */
|
||||
focusIndex = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
||||
ok(focusIndex == 1, "got %d\n", focusIndex);
|
||||
|
||||
selectionIndex = SendMessageA(hTab, TCM_SETCURSEL, -1, 0);
|
||||
ok(selectionIndex == 1, "got %d\n", selectionIndex);
|
||||
|
||||
memset(&tcItem, 0, sizeof(TCITEMA));
|
||||
|
||||
/* focus is reset too */
|
||||
focusIndex = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
||||
ok(focusIndex == -1, "got %d\n", focusIndex);
|
||||
|
||||
tcItem.mask = TCIF_STATE;
|
||||
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
|
||||
SendMessageA(hTab, TCM_GETITEMA, selectionIndex, (LPARAM)&tcItem);
|
||||
ok(tcItem.dwState == 0, "got state %d\n", tcItem.dwState);
|
||||
|
||||
DestroyWindow(hTab);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue