[AD] Disable close button support with user window (Windows)

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


The attached patch disables the close button support when a user registers a 
user window with win_set_window() under Windows. This is necessary because, 
otherwise, the close button is automatically greyed out by Allegro, which I 
think is not very nice since the user is supposed to retain full control 
over the window in this situation.

Applied to mainline (not needed on 4.0 branch because of the different 
handling of the close button).

-- 
Eric Botcazou
Index: src/win/wwnd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wwnd.c,v
retrieving revision 1.75
diff -u -r1.75 wwnd.c
--- src/win/wwnd.c	19 May 2003 11:24:51 -0000	1.75
+++ src/win/wwnd.c	27 Oct 2003 16:30:04 -0000
@@ -623,6 +623,7 @@
  */
 void win_set_window(HWND wnd)
 {
+   static int (*saved_scbc)(void (*proc)(void)) = NULL;
    struct WINDOW_MODULES wm;
 
    if (_allegro_count > 0) {
@@ -631,6 +632,19 @@
    }
 
    user_wnd = wnd;
+
+   /* The user retains full control over the close button if he registers
+      a user-defined window. */
+   if (user_wnd) {
+      if (!saved_scbc)
+         saved_scbc = system_directx.set_close_button_callback;
+
+      system_directx.set_close_button_callback = NULL;
+   }
+   else {
+      if (saved_scbc)
+         system_directx.set_close_button_callback = saved_scbc;
+   }
 
    if (_allegro_count > 0) {
       init_directx_window();


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