Author: gedmurphy
Date: Wed Dec  9 21:55:19 2015
New Revision: 70319
URL: 
http://svn.reactos.org/svn/reactos?rev=70319&view=rev
Log:
[CHARMAP]
- Don't go past the scroll range
- Reset the grid/cell info when a new font is selected
- Should fix some of the issues Vort listed in CORE-10518
Modified:
    trunk/reactos/base/applications/charmap/map.c
    trunk/reactos/base/applications/charmap/precomp.h
Modified: trunk/reactos/base/applications/charmap/map.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/map.c       [iso-8859-1] (original)
+++ trunk/reactos/base/applications/charmap/map.c       [iso-8859-1] Wed Dec  9 21:55:19
2015
@@ -221,7 +221,7 @@
     HDC hdc;
     WCHAR ch[MAX_GLYPHS];
     WORD out[MAX_GLYPHS];
-    DWORD i, j, Rows;
+    DWORD i, j;
     /* Destroy Zoom window, since it was created with older font */
     DestroyWindow(infoPtr->hLrgWnd);
@@ -247,12 +247,7 @@
                    NULL,
                    TRUE);
-    /* Test if zoom window must be reopened */
-    if (infoPtr->pActiveCell != NULL &&
-        infoPtr->pActiveCell->bLarge)
-    {
-        CreateLargeCell(infoPtr);
-    }
+    infoPtr->pActiveCell = &infoPtr->Cells[0][0];
     // Get all the valid glyphs in this font
@@ -281,11 +276,14 @@
     ReleaseDC(infoPtr->hMapWnd, hdc);
-    Rows = infoPtr->NumValidGlyphs / XCELLS;
+    infoPtr->NumRows = infoPtr->NumValidGlyphs / XCELLS;
     if (infoPtr->NumValidGlyphs % XCELLS)
-        Rows += 1;
-
-    SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, Rows - YCELLS, FALSE);
+        infoPtr->NumRows += 1;
+    infoPtr->NumRows = (infoPtr->NumRows > YCELLS) ? infoPtr->NumRows -
YCELLS : 0;
+
+    SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, infoPtr->NumRows, FALSE);
+    SetScrollPos(infoPtr->hMapWnd, SB_VERT, 0, TRUE);
+    infoPtr->iYStart = 0;
 }
@@ -463,7 +461,8 @@
             break;
        }
-    infoPtr->iYStart = max(0, min(infoPtr->iYStart, MAX_ROWS));
+    infoPtr->iYStart = max(0, infoPtr->iYStart);
+    infoPtr->iYStart = min(infoPtr->iYStart, infoPtr->NumRows);
     iYDiff = iOldYStart - infoPtr->iYStart;
     if (iYDiff)
Modified: trunk/reactos/base/applications/charmap/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/precomp.h   [iso-8859-1] (original)
+++ trunk/reactos/base/applications/charmap/precomp.h   [iso-8859-1] Wed Dec  9 21:55:19
2015
@@ -47,6 +47,7 @@
     HFONT hFont;
     LOGFONTW CurrentFont;
     INT iYStart;
+    INT NumRows;
     USHORT ValidGlyphs[MAX_GLYPHS];
     USHORT NumValidGlyphs;