[ros-diffs] [tkreuzer] 26840: fix drawing on resize

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sat May 19 16:23:00 CEST 2007


Author: tkreuzer
Date: Sat May 19 18:23:00 2007
New Revision: 26840

URL: http://svn.reactos.org/svn/reactos?rev=26840&view=rev
Log:
fix drawing on resize

Modified:
    trunk/rosapps/fontview/display.c

Modified: trunk/rosapps/fontview/display.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/display.c?rev=26840&r1=26839&r2=26840&view=diff
==============================================================================
--- trunk/rosapps/fontview/display.c (original)
+++ trunk/rosapps/fontview/display.c Sat May 19 18:23:00 2007
@@ -178,7 +178,7 @@
 
 	BeginPaint(hwnd, &ps);
 
-	/* fill with white */
+	/* Fill with white */
 	FillRect(ps.hdc, &ps.rcPaint, GetStockObject(WHITE_BRUSH));
 
 	/* Draw the text */
@@ -193,17 +193,34 @@
 Display_OnSize(HWND hwnd)
 {
 	RECT rect;
-	SCROLLINFO si; 
+	SCROLLINFO si;
+	int nOldPos;
 
 	GetClientRect(hwnd, &rect);
 
+	/* Get the old pos */
+	si.cbSize = sizeof(si);
+	si.fMask  = SIF_POS;
+	GetScrollInfo(hwnd, SB_VERT, &si);
+	nOldPos = si.nPos;
+
 	/* Set the new page size */
-	si.cbSize = sizeof(si);
 	si.fMask  = SIF_PAGE;
 	si.nPage  = rect.bottom;
-	SetScrollInfo(hwnd, SB_VERT, &si, TRUE); 
-// FIXME: handle exceeding of current pos -> redraw entire window
-// if new page size is < curent pos: current pos = maximum whatever and then redraw
+	SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+
+	/* Get the new pos */
+	si.fMask  = SIF_POS;
+	GetScrollInfo(hwnd, SB_VERT, &si);
+
+	/* If the don't match ... */
+	if (nOldPos != si.nPos)
+	{
+		/* ... scroll the window */
+		ScrollWindowEx(hwnd, 0, -(si.nPos - nOldPos), NULL, NULL, NULL, NULL, SW_INVALIDATE);
+		UpdateWindow(hwnd);
+	}
+
 	return 0;
 }
 
@@ -231,7 +248,7 @@
 		case SB_LINEDOWN:
 			nPos = si.nPos + 10;
 			break;
-//		case SB_THUMBTRACK:
+		case SB_THUMBTRACK:
 		case SB_THUMBPOSITION:
 			nPos = si.nTrackPos;
 			break;




More information about the Ros-diffs mailing list