diff win/dw.c @ 157:a07dd2e819f3

Added module support.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 12 Nov 2002 08:52:22 +0000
parents 840c54766306
children c555d06b6c93
line wrap: on
line diff
--- a/win/dw.c	Fri Nov 08 17:38:59 2002 +0000
+++ b/win/dw.c	Tue Nov 12 08:52:22 2002 +0000
@@ -2303,28 +2303,33 @@
 			{
 				POINT point;
 				RECT rect;
+				static POINT lastpoint;
 
 				GetCursorPos(&point);
 				GetWindowRect(hwnd, &rect);
 
-				if(PtInRect(&rect, point))
+				if(memcmp(&point, &lastpoint, sizeof(POINT)))
 				{
-					int width = (rect.right - rect.left);
-					int height = (rect.bottom - rect.top);
-
-					if(type == BOXHORZ)
+					if(PtInRect(&rect, point))
 					{
-						start = point.x - rect.left;
-						if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
-							*percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
+						int width = (rect.right - rect.left);
+						int height = (rect.bottom - rect.top);
+
+						if(type == BOXHORZ)
+						{
+							start = point.x - rect.left;
+							if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
+								*percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
+						}
+						else
+						{
+							start = point.y - rect.top;
+							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);
 					}
-					else
-					{
-						start = point.y - rect.top;
-						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);
+					memcpy(&lastpoint, &point, sizeof(POINT));
 				}
 			}
 			break;
@@ -6402,6 +6407,49 @@
 	Beep(freq, dur);
 }
 
+/* Open a shared library and return a handle.
+ * Parameters:
+ *         name: Base name of the shared library.
+ *         handle: Pointer to a module handle,
+ *                 will be filled in with the handle.
+ */
+int dw_module_load(char *name, HMOD *handle)
+{
+	if(!handle)
+		return	-1;
+
+	*handle = LoadLibrary(name);
+	return (NULL == *handle);
+}
+
+/* Queries the address of a symbol within open handle.
+ * Parameters:
+ *         handle: Module handle returned by dw_module_load()
+ *         name: Name of the symbol you want the address of.
+ *         func: A pointer to a function pointer, to obtain
+ *               the address.
+ */
+int dw_module_symbol(HMOD handle, char *name, void**func)
+{
+	if(!func || !name)
+		return	-1;
+
+	if(0 == strlen(name))
+		return	-1;
+
+	*func = (void*)GetProcAddress(handle, name);
+	return	(NULL == *func);
+}
+
+/* Frees the shared library previously opened.
+ * Parameters:
+ *         handle: Module handle returned by dw_module_load()
+ */
+int dw_module_close(HMOD handle)
+{
+	return FreeLibrary(handle);
+}
+
 /*
  * Returns the handle to an unnamed mutex semaphore.
  */