[CHARMAP]
authorGed Murphy <gedmurphy@reactos.org>
Wed, 9 Dec 2015 21:55:19 +0000 (21:55 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Wed, 9 Dec 2015 21:55:19 +0000 (21:55 +0000)
- 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

svn path=/trunk/; revision=70319

reactos/base/applications/charmap/map.c
reactos/base/applications/charmap/precomp.h

index 13b20a4..383d98f 100644 (file)
@@ -221,7 +221,7 @@ SetFont(PMAP infoPtr,
     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 @@ SetFont(PMAP infoPtr,
                    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 @@ SetFont(PMAP infoPtr,
 
     ReleaseDC(infoPtr->hMapWnd, hdc);
 
-    Rows = infoPtr->NumValidGlyphs / XCELLS;
+    infoPtr->NumRows = infoPtr->NumValidGlyphs / XCELLS;
     if (infoPtr->NumValidGlyphs % XCELLS)
-        Rows += 1;
+        infoPtr->NumRows += 1;
+    infoPtr->NumRows = (infoPtr->NumRows > YCELLS) ? infoPtr->NumRows - YCELLS : 0;
 
-    SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, Rows - YCELLS, FALSE);
+    SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, infoPtr->NumRows, FALSE);
+    SetScrollPos(infoPtr->hMapWnd, SB_VERT, 0, TRUE);
+    infoPtr->iYStart = 0;
 }
 
 
@@ -463,7 +461,8 @@ OnVScroll(PMAP infoPtr,
             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)
index dc1b863..872cbe2 100644 (file)
@@ -47,6 +47,7 @@ typedef struct _MAP
     HFONT hFont;
     LOGFONTW CurrentFont;
     INT iYStart;
+    INT NumRows;
 
     USHORT ValidGlyphs[MAX_GLYPHS];
     USHORT NumValidGlyphs;