Fix game-list highight error when filtered (WB)
[xboard.git] / winboard / wgamelist.c
index 2300fda..80ce9b6 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
  * wgamelist.c -- Game list window for WinBoard\r
  *\r
- * Copyright 1995, 2009, 2010 Free Software Foundation, Inc.\r
+ * Copyright 1995, 2009, 2010, 2011 Free Software Foundation, Inc.\r
  *\r
  * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
@@ -406,9 +406,15 @@ VOID GameListPopDown(void)
 \r
 VOID GameListHighlight(int index)\r
 {\r
+  char buf[MSG_SIZ];\r
+  int i, res = 0;\r
   if (gameListDialog == NULL) return;\r
+  for(i=0; res != LB_ERR; i++) {\r
+        res = SendDlgItemMessage( gameListDialog, OPT_GameListText, LB_GETTEXT, i, (LPARAM)buf );\r
+        if(index <= atoi( buf )) break;\r
+  }\r
   SendDlgItemMessage(gameListDialog, OPT_GameListText,\r
-    LB_SETCURSEL, index - 1, 0);\r
+    LB_SETCURSEL, i, 0);\r
 }\r
 \r
 \r