- iSelected should be -1 if no item selected (Gerard Patel)
- some of the checks for invalid items where > when they should have been >= (Marcus Meissner) - made InsertItem behave similarly to DeleteItem, ie, if the current item is after where the item is inserted, increment the selected item (David Luyer)
This commit is contained in:
parent
dc6f327a8d
commit
b1f173da52
|
@ -125,7 +125,7 @@ TAB_SetCurFocus (HWND hwnd,WPARAM wParam)
|
|||
TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
|
||||
INT iItem=(INT) wParam;
|
||||
|
||||
if ((iItem < 0) || (iItem > infoPtr->uNumItem)) return 0;
|
||||
if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
|
||||
|
||||
infoPtr->uFocus=iItem;
|
||||
if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
|
||||
|
@ -1296,6 +1296,7 @@ TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
if (infoPtr->uNumItem == 0) {
|
||||
infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
|
||||
infoPtr->uNumItem++;
|
||||
infoPtr->iSelected = 0;
|
||||
}
|
||||
else {
|
||||
TAB_ITEM *oldItems = infoPtr->items;
|
||||
|
@ -1316,6 +1317,9 @@ TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
}
|
||||
|
||||
if (iItem <= infoPtr->iSelected)
|
||||
infoPtr->iSelected++;
|
||||
|
||||
COMCTL32_Free (oldItems);
|
||||
}
|
||||
|
||||
|
@ -1370,7 +1374,7 @@ TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
iItem=(INT) wParam;
|
||||
tabItem=(LPTCITEMA ) lParam;
|
||||
TRACE("%d %p\n",iItem, tabItem);
|
||||
if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE;
|
||||
if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
|
||||
|
||||
wineItem=& infoPtr->items[iItem];
|
||||
|
||||
|
@ -1422,7 +1426,7 @@ TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
iItem=(INT) wParam;
|
||||
tabItem=(LPTCITEMA) lParam;
|
||||
TRACE("\n");
|
||||
if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE;
|
||||
if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
|
||||
|
||||
wineItem=& infoPtr->items[iItem];
|
||||
|
||||
|
@ -1476,6 +1480,9 @@ TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
if (iItem < infoPtr->iSelected)
|
||||
infoPtr->iSelected--;
|
||||
|
||||
if (infoPtr->uNumItem == 0)
|
||||
infoPtr->iSelected = -1;
|
||||
|
||||
/*
|
||||
* Reposition and repaint tabs.
|
||||
*/
|
||||
|
@ -1494,7 +1501,8 @@ TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
|
||||
|
||||
COMCTL32_Free (infoPtr->items);
|
||||
infoPtr->uNumItem=0;
|
||||
infoPtr->uNumItem = 0;
|
||||
infoPtr->iSelected = -1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1607,7 +1615,7 @@ TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
infoPtr->hFont = 0;
|
||||
infoPtr->items = 0;
|
||||
infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
|
||||
infoPtr->iSelected = 0;
|
||||
infoPtr->iSelected = -1;
|
||||
infoPtr->uFocus = 0;
|
||||
infoPtr->hwndToolTip = 0;
|
||||
infoPtr->DoRedraw = TRUE;
|
||||
|
|
Loading…
Reference in New Issue