diff win/dw.c @ 127:c5c3ccb84ac7

Safety checks in the splitbar calculations on OS/2 and Windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 20 Oct 2002 06:10:31 +0000
parents 72cb88af4490
children e47c52b37cdd
line wrap: on
line diff
--- a/win/dw.c	Sun Oct 20 05:39:02 2002 +0000
+++ b/win/dw.c	Sun Oct 20 06:10:31 2002 +0000
@@ -2293,7 +2293,7 @@
 			else
 				SetCursor(LoadCursor(NULL, IDC_SIZENS));
 
-			if(GetCapture() == hwnd)
+			if(GetCapture() == hwnd && percent)
 			{
 				POINT point;
 				RECT rect;
@@ -2309,12 +2309,14 @@
 					if(type == BOXHORZ)
 					{
 						start = point.x - rect.left;
-						*percent = ((float)start / (float)(rect.right - rect.left - SPLITBAR_WIDTH)) * 100.0;
+						if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
+							*percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
 					}
 					else
 					{
 						start = point.y - rect.top;
-						*percent = ((float)start / (float)(rect.bottom - rect.top - SPLITBAR_WIDTH)) * 100.0;
+						if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH)
+							*percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0;
 					}
 					_handle_splitbar_resize(hwnd, *percent, type, width, height);
 				}