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

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 19 08:17:37 CDT 2007


Module: wine
Branch: master
Commit: 637a6116e2bb10689a22e3d24524174cc0dfd370
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=637a6116e2bb10689a22e3d24524174cc0dfd370

Author: Hagop Hagopian <shaitani at gmail.com>
Date:   Sat Mar 17 14:16:08 2007 -0800

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

---

 dlls/comctl32/tab.c       |   54 ++++++++++++++++++++------------------------
 dlls/comctl32/tests/tab.c |    7 +-----
 2 files changed, 26 insertions(+), 35 deletions(-)

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




More information about the wine-cvs mailing list