[AD] Resizeable windows hook

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


This patch allows a program to hook the window resize, so a user defined
function can interpret a window resize anywy it wants. I know Allegro
doesn't support resizeable windows (in Windows at least), but this is
for AllegroGL, where a window can be resized. This patch only applied to
the Windows version, as I have no idea what it would take to do the same
for X and BeOS. I'd hope that someone would take on this feat. Well
anyway, here's the patch.


--

- Robert J Ohannessian
--- /cvs/allegro/src/win/wwnd.c	Tue Aug 15 07:30:06 2000
+++ /allegro/src/win/wwnd.c	Thu Dec 21 14:20:44 2000
@@ -31,6 +31,7 @@
 static WNDPROC user_wnd_proc = NULL;
 static HANDLE wnd_thread = NULL;
 static HWND (*wnd_create_proc)(WNDPROC) = NULL;
+static void (*user_window_resize_proc)(int, int) = NULL;
 int wnd_x = 0;
 int wnd_y = 0;
 int wnd_width = 0;
@@ -164,6 +165,10 @@
       case WM_SIZE:
 	 wnd_width = LOWORD(lparam);
 	 wnd_height = HIWORD(lparam);
+         
+         if (user_window_resize_proc)
+            user_window_resize_proc(wnd_width, wnd_height);
+
 	 break;
 
       case WM_NCPAINT:
@@ -214,6 +219,18 @@
    else
       return DefWindowProc(wnd, message, wparam, lparam);
 }
+
+
+/* hook_resize_proc
+ *  Hooks a user defined resize procedure. It will be called whenever
+ *  the window is resized. The window must be resizable.
+ */
+void hook_resize_proc(void (*proc)(int,int))
+{
+   user_window_resize_proc = proc;
+   return;
+}
+
 
 
 
--- /cvs/allegro/include/allegro/aintwin.h	Sun Oct 15 07:32:42 2000
+++ /allegro/include/allegro/aintwin.h	Thu Dec 21 14:31:16 2000
@@ -54,6 +54,7 @@
 AL_FUNC(void, set_sync_timer_freq, (int freq));
 AL_FUNC(void, handle_window_size, (int x, int y, int w, int h));
 AL_FUNC(void, restore_window_style, (void));
+AL_FUNC(void, hook_resize_proc, (void (*proc)(int, int)));
 
 /* Stuff moved over from wddraw.h */
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/