Commit 637a6116 authored by Hagop Hagopian's avatar Hagop Hagopian Committed by Alexandre Julliard

comctl32: tab: Minor bug fixes in the curSel and curFocus getters and setters.

parent 62d3be77
...@@ -231,19 +231,10 @@ static inline LRESULT TAB_GetCurSel (const TAB_INFO *infoPtr) ...@@ -231,19 +231,10 @@ static inline LRESULT TAB_GetCurSel (const TAB_INFO *infoPtr)
} }
/* RETURNS /* RETURNS
* the index of the tab item that has the focus * the index of the tab item that has the focus. */
* NOTE
* we have not to return negative value
* TODO
* test for windows */
static inline LRESULT static inline LRESULT
TAB_GetCurFocus (const TAB_INFO *infoPtr) TAB_GetCurFocus (const TAB_INFO *infoPtr)
{ {
if (infoPtr->uFocus<0)
{
FIXME("we have not to return negative value\n");
return 0;
}
return infoPtr->uFocus; return infoPtr->uFocus;
} }
...@@ -255,10 +246,13 @@ static inline LRESULT TAB_GetToolTips (const TAB_INFO *infoPtr) ...@@ -255,10 +246,13 @@ static inline LRESULT TAB_GetToolTips (const TAB_INFO *infoPtr)
static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem) static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem)
{ {
INT prevItem = -1; INT prevItem = infoPtr->iSelected;
if (iItem >= 0 && iItem < infoPtr->uNumItem) { if (iItem < 0)
prevItem=infoPtr->iSelected; infoPtr->iSelected=-1;
else if (iItem >= infoPtr->uNumItem)
return -1;
else {
if (infoPtr->iSelected != iItem) { if (infoPtr->iSelected != iItem) {
infoPtr->iSelected=iItem; infoPtr->iSelected=iItem;
TAB_EnsureSelectionVisible(infoPtr); TAB_EnsureSelectionVisible(infoPtr);
...@@ -270,23 +264,25 @@ static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem) ...@@ -270,23 +264,25 @@ static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem)
static LRESULT TAB_SetCurFocus (TAB_INFO *infoPtr, INT iItem) static LRESULT TAB_SetCurFocus (TAB_INFO *infoPtr, INT iItem)
{ {
if (iItem < 0 || iItem >= infoPtr->uNumItem) return 0; if (iItem < 0)
infoPtr->uFocus = -1;
if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { else if (iItem < infoPtr->uNumItem) {
FIXME("Should set input focus\n"); if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) {
} else { FIXME("Should set input focus\n");
int oldFocus = infoPtr->uFocus; } else {
if (infoPtr->iSelected != iItem || oldFocus == -1 ) { int oldFocus = infoPtr->uFocus;
infoPtr->uFocus = iItem; if (infoPtr->iSelected != iItem || oldFocus == -1 ) {
if (oldFocus != -1) { infoPtr->uFocus = iItem;
if (!TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGING)) { if (oldFocus != -1) {
infoPtr->iSelected = iItem; if (!TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGING)) {
TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGE); infoPtr->iSelected = iItem;
TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGE);
}
else
infoPtr->iSelected = iItem;
TAB_EnsureSelectionVisible(infoPtr);
TAB_InvalidateTabArea(infoPtr);
} }
else
infoPtr->iSelected = iItem;
TAB_EnsureSelectionVisible(infoPtr);
TAB_InvalidateTabArea(infoPtr);
} }
} }
} }
......
...@@ -663,9 +663,7 @@ static void test_getters_setters(INT nTabs) ...@@ -663,9 +663,7 @@ static void test_getters_setters(INT nTabs)
/* Testing CurFocus with negative value */ /* Testing CurFocus with negative value */
SendMessage(hTab, TCM_SETCURFOCUS, -10, 0); SendMessage(hTab, TCM_SETCURFOCUS, -10, 0);
focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
todo_wine{
expect(-1, focusIndex); expect(-1, focusIndex);
}
/* Testing CurFocus with value larger than number of tabs */ /* Testing CurFocus with value larger than number of tabs */
focusIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0); focusIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
...@@ -697,15 +695,12 @@ static void test_getters_setters(INT nTabs) ...@@ -697,15 +695,12 @@ static void test_getters_setters(INT nTabs)
/* Testing CurSel with negative value */ /* Testing CurSel with negative value */
SendMessage(hTab, TCM_SETCURSEL, -10, 0); SendMessage(hTab, TCM_SETCURSEL, -10, 0);
selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0); selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
todo_wine{
expect(-1, selectionIndex); expect(-1, selectionIndex);
}
/* Testing CurSel with value larger than number of tabs */ /* Testing CurSel with value larger than number of tabs */
selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0); selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
todo_wine{
expect(-1, selectionIndex); expect(-1, selectionIndex);
}
selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs+1, 0); selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs+1, 0);
expect(-1, selectionIndex); expect(-1, selectionIndex);
selectionIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); selectionIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
......
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