changeset 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 ac616f625443
files os2/dw.c win/dw.c
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sun Oct 20 05:39:02 2002 +0000
+++ b/os2/dw.c	Sun Oct 20 06:10:31 2002 +0000
@@ -2454,12 +2454,14 @@
 					if(type == BOXHORZ)
 					{
 						start = rclFrame.xLeft - rclBounds.xLeft;
-						*percent = ((float)start / (float)(rclBounds.xRight - rclBounds.xLeft - SPLITBAR_WIDTH)) * 100.0;
+						if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
+							*percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
 					}
 					else
 					{
 						start = rclFrame.yBottom - rclBounds.yBottom;
-						*percent = 100.0 - (((float)start / (float)(rclBounds.yTop - rclBounds.yBottom - SPLITBAR_WIDTH)) * 100.0);
+						if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH)
+							*percent = 100.0 - (((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0);
 					}
 					_handle_splitbar_resize(hwnd, *percent, type, width, height);
 				}
--- 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);
 				}