Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs16:/tmp/cvs-serv13267/src

Modified Files:
	mswindow.c 
Log Message:
Moved reinitialization of SDB buffers from WM_EXITSIZEMOVE to WM_SIZE,
as moving to the latter ensures correct clipping rectangle is set.
Moved initstars() to be after TWINSIDE is changed, fixes regression.

Index: mswindow.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- mswindow.c	14 Apr 2007 09:49:35 -0000	1.74
+++ mswindow.c	18 Apr 2007 02:05:26 -0000	1.75
@@ -1857,6 +1857,25 @@
         win->ClipRect.left = win->ClipRect.top = win->border;
         win->ClipRect.right = LOWORD (lParam) - win->border;
         win->ClipRect.bottom = HIWORD (lParam) - win->border;
+        // Reinitialize SDB as size/borders of window have changed
+        if ((Window *) w != NULL && win->hwnd == ((Window *) w)->hwnd)
+        {
+            SelectObject (localSDB->mem_dc, localSDB->old_bmp);
+            DeleteObject (localSDB->mem_bmp);
+            ReleaseDC (((Window *)localSDB->window)->hwnd, localSDB->win_dc);
+            DeleteDC (localSDB->mem_dc);
+            free (localSDB);
+            localSDB = W_InitSDB (w);
+        }
+        else if ((Window *) mapw != NULL && win->hwnd == ((Window *) mapw)->hwnd)
+        {
+            SelectObject (mapSDB->mem_dc, mapSDB->old_bmp);
+            DeleteObject (mapSDB->mem_bmp);
+            ReleaseDC (((Window *)mapSDB->window)->hwnd, mapSDB->win_dc);
+            DeleteDC (mapSDB->mem_dc);
+            free (mapSDB);
+            mapSDB = W_InitSDB (mapw);
+        }
         break;
 
     case WM_ENTERSIZEMOVE:
@@ -1933,27 +1952,16 @@
 
         GET_STRUCT_PTR;
 
-        // Reinitialize whatever is necessary (so many things are created based on
-        // a fixed TWINSIDE)
         // Adjust window to be square
-        // Adjust TWINSIDE and GWINSIDE
-        // Redo critical windows
-        // Clear window
+        // Adjust TWINSIDE or GWINSIDE
+        // Reinitialize whatever is necessary
+        // Redo other critical windows
+        // Move and refresh window
         if (windowMove && (Window *) w != NULL && win->hwnd == ((Window *) w)->hwnd)
         { 
             GetWindowRect (((Window *) w)->hwnd, &winRect);
             GetWindowRect (((Window *) baseWin)->hwnd, &baseRect);
 
-            // Have to reinitialize SDB
-            SelectObject (localSDB->mem_dc, localSDB->old_bmp);
-            DeleteObject (localSDB->mem_bmp);
-            ReleaseDC (((Window *)localSDB->window)->hwnd, localSDB->win_dc);
-            DeleteDC (localSDB->mem_dc);
-            free (localSDB);
-            localSDB = W_InitSDB (w);
-            // and stars
-            initStars();
-
             // Keep window square
             width = winRect.right - winRect.left;
             height = winRect.bottom - winRect.top;
@@ -1963,6 +1971,9 @@
                 height = width;
             TWINSIDE = width - 2 * win->border;
 
+            // Have to reinitialize stars
+            initStars();
+ 
             /* Beeplite TTS may need to be adjusted */
             tts_ypos = intDefault("tts_ypos", TWINSIDE / 2 - 16);
 
@@ -1990,10 +2001,7 @@
                 winRect.left -= GetSystemMetrics (SM_CXSIZEFRAME) - 1;
                 winRect.top -= GetSystemMetrics (SM_CYSIZEFRAME) - 1;
             }
- 
-            MoveWindow (((Window *) w)->hwnd, winRect.left, winRect.top,
-                        width, height, TRUE);
- 
+
             // All windows based on TWINSIDE are out of position now, but the team
             // select/quit windows are now the wrong size too, so we need to redo them
             for (i = 0; i < 4; i++)
@@ -2004,13 +2012,15 @@
                 if (!ingame)
                     W_MapWindow (teamWin[i]);
             }
-
             W_UnmapWindow (qwin);
             qwin = W_MakeWindow ("quit", 4 * (TWINSIDE / 5), TWINSIDE - (TWINSIDE / 5), (TWINSIDE / 5),
                                  (TWINSIDE / 5), w, 1, foreColor);
             if (!ingame)
                 W_MapWindow (qwin);
 
+            MoveWindow (((Window *) w)->hwnd, winRect.left, winRect.top,
+                        width, height, TRUE);
+
             W_FastClear = 1;
             if (viewBox)
                 redrawall = 1;
@@ -2020,14 +2030,6 @@
             GetWindowRect (((Window *) mapw)->hwnd, &winRect);
             GetWindowRect (((Window *) baseWin)->hwnd, &baseRect);
 
-            // Have to reinitialize SDB
-            SelectObject (mapSDB->mem_dc, mapSDB->old_bmp);
-            DeleteObject (mapSDB->mem_bmp);
-            ReleaseDC (((Window *)mapSDB->window)->hwnd, mapSDB->win_dc);
-            DeleteDC (mapSDB->mem_dc);
-            free (mapSDB);
-            mapSDB = W_InitSDB (mapw);
-
             // Keep window square
             width = winRect.right - winRect.left;
             height = winRect.bottom - winRect.top;