Commit b1f173da authored by David Luyer's avatar David Luyer Committed by Alexandre Julliard

- 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)
parent dc6f327a
......@@ -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;
......@@ -1315,7 +1316,10 @@ TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
(infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
}
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;
......
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