Index: trunk/src/user32/oslibmsgtranslate.cpp
===================================================================
--- trunk/src/user32/oslibmsgtranslate.cpp	(revision 5232)
+++ trunk/src/user32/oslibmsgtranslate.cpp	(revision 5236)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsgtranslate.cpp,v 1.40 2000-12-29 18:39:58 sandervl Exp $ */
+/* $Id: oslibmsgtranslate.cpp,v 1.41 2001-02-21 20:51:06 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -375,14 +375,18 @@
         break;
 
+    case WM_BUTTON2CLICK:
+    case WM_BUTTON1CLICK:
+    case WM_BUTTON3CLICK:
+        goto dummymessage;
+
     case WM_BUTTON2MOTIONSTART:
     case WM_BUTTON2MOTIONEND:
-    case WM_BUTTON2CLICK:
     case WM_BUTTON1MOTIONSTART:
     case WM_BUTTON1MOTIONEND:
-    case WM_BUTTON1CLICK:
     case WM_BUTTON3MOTIONSTART:
     case WM_BUTTON3MOTIONEND:
-    case WM_BUTTON3CLICK:
-        goto dummymessage;
+        //no break; translate to WM_MOUSEMOVE
+        //Some applications (e.g. Unreal) retrieve all mouse messages
+        //when a mouse button is pressed and don't expect WM_NULL
 
     case WM_MOUSEMOVE:
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 5232)
+++ trunk/src/user32/win32wbase.cpp	(revision 5236)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.239 2001-02-20 17:22:05 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.240 2001-02-21 20:51:06 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -849,7 +849,10 @@
 
     if(fShow) {
-            setStyle(getStyle() | WS_VISIBLE);
-    }
-    else    setStyle(getStyle() & ~WS_VISIBLE);
+         setStyle(getStyle() | WS_VISIBLE);
+         if(getStyle() & WS_MINIMIZE) {
+            return ShowWindow(SW_RESTORE);
+         }
+    }
+    else setStyle(getStyle() & ~WS_VISIBLE);
 
     return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
@@ -1058,5 +1061,5 @@
 //******************************************************************************
 //******************************************************************************
-ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
+ULONG Win32BaseWindow::MsgPaint(ULONG tmp, ULONG select)
 {
     if (select && IsWindowIconic())
@@ -1588,12 +1591,12 @@
         if( hdc )
         {
-          if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() && hIcon))
-          {
-            int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
-            int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
-            dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
-            DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() );
-          }
-          EndPaint(getWindowHandle(), &ps );
+            if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() || hIcon))
+            {
+                int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
+                int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
+                dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
+                DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() );
+            }
+            EndPaint(getWindowHandle(), &ps );
         }
         return 0;
@@ -2170,4 +2173,5 @@
  BOOL  rc,wasVisible,showFlag;
  RECT  newPos = {0, 0, 0, 0};
+ BOOL  fInvalidate = FALSE;
 
     dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
@@ -2182,5 +2186,5 @@
         break;
 
-    case SW_SHOWMINNOACTIVE:
+	case SW_SHOWMINNOACTIVE:
         swp |= SWP_NOACTIVATE | SWP_NOZORDER;
         /* fall through */
@@ -2189,20 +2193,33 @@
         /* fall through */
     case SW_MINIMIZE:
-        swp |= SWP_FRAMECHANGED;
-        if( !(getStyle() & WS_MINIMIZE) )
-             swp |= MinMaximize(SW_MINIMIZE, &newPos );
+//testesteest
+        if(!(getStyle() & WS_CHILD))
+        {
+            if( !(getStyle() & WS_MINIMIZE) )
+                 swp |= MinMaximize(SW_MINIMIZE, &newPos );
+
+            swp |= SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW;
+        }
+        else {
+            swp |= SWP_FRAMECHANGED;
+            if( !(getStyle() & WS_MINIMIZE) ) {
+                 swp |= MinMaximize(SW_MINIMIZE, &newPos );
+                 fInvalidate = TRUE;
+            }
+            else swp |= SWP_NOSIZE | SWP_NOMOVE;
+        }
+//testesteest
+        break;
+
+    case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
+        swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
+        if( !(getStyle() & WS_MAXIMIZE) )
+             swp |= MinMaximize(SW_MAXIMIZE, &newPos );
         else swp |= SWP_NOSIZE | SWP_NOMOVE;
         break;
 
-    case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
-            swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
-            if( !(getStyle() & WS_MAXIMIZE) )
-         swp |= MinMaximize(SW_MAXIMIZE, &newPos );
-            else swp |= SWP_NOSIZE | SWP_NOMOVE;
-            break;
-
     case SW_SHOWNA:
-            swp |= SWP_NOACTIVATE | SWP_NOZORDER;
-            /* fall through */
+        swp |= SWP_NOACTIVATE | SWP_NOZORDER;
+        /* fall through */
     case SW_SHOW:
         swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
@@ -2269,4 +2286,7 @@
         SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
     }
+    if(fInvalidate) {
+        InvalidateRect(getWindowHandle(), NULL, 1);
+    }
 END:
     return wasVisible;
@@ -2411,13 +2431,13 @@
         if(hTaskList) {
             dprintf(("Adding window %x to tasklist", getWindowHandle()));
-            OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
+            OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), 1);
         }
     }
     else
-    if(fuFlags & SWP_HIDEWINDOW && IsWindowVisible()) {
+    if((fuFlags & SWP_HIDEWINDOW) && IsWindowVisible()) {
         setStyle(getStyle() & ~WS_VISIBLE);
-        if(hTaskList) {
+        if(hTaskList && !(getStyle() & WS_MINIMIZE)) {
             dprintf(("Removing window %x from tasklist", getWindowHandle()));
-            OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
+            OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), 0);
         }
     }
@@ -2534,9 +2554,9 @@
    if(getStyle() & WS_MINIMIZE )
    {
-    //TODO: Why can't this be (0,0)?
-    if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
-        SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
-                     0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
-    }
+        //TODO: Why can't this be (0,0)?
+        if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
+            SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
+                         0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+        }
    }
    else
Index: trunk/src/user32/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/win32wbasenonclient.cpp	(revision 5232)
+++ trunk/src/user32/win32wbasenonclient.cpp	(revision 5236)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.28 2001-02-20 17:22:06 sandervl Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.29 2001-02-21 20:51:07 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -1013,146 +1013,148 @@
 VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
 {
-  BOOL active  = flags & WIN_NCACTIVATED;
-  HDC hdc;
-  RECT rect,rectClip,rfuzz;
-
-  /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
-     the call to GetDCEx implying that it is allowed not to use it either.
-     However, the suggested GetDCEx(    , DCX_WINDOW | DCX_INTERSECTRGN)
-     will cause clipRgn to be deleted after ReleaseDC().
-     Now, how is the "system" supposed to tell what happened?
-   */
-
-  dprintf(("DoNCPaint %x %x %d", getWindowHandle(), clip, suppress_menupaint));
-  DecreaseLogCount();
-
-  rect.top    = rect.left = 0;
-  rect.right  = rectWindow.right - rectWindow.left;
-  rect.bottom = rectWindow.bottom - rectWindow.top;
-
-  if (clip > 1)
-  {
-    //only redraw caption
-    GetRgnBox(clip,&rectClip);
+    BOOL active  = flags & WIN_NCACTIVATED;
+    HDC hdc;
+    RECT rect,rectClip,rfuzz;
+
+    /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
+       the call to GetDCEx implying that it is allowed not to use it either.
+       However, the suggested GetDCEx(    , DCX_WINDOW | DCX_INTERSECTRGN)
+       will cause clipRgn to be deleted after ReleaseDC().
+       Now, how is the "system" supposed to tell what happened?
+    */
+
+    dprintf(("DoNCPaint %x %x %d", getWindowHandle(), clip, suppress_menupaint));
+    DecreaseLogCount();
+
+    rect.top    = rect.left = 0;
+    rect.right  = rectWindow.right - rectWindow.left;
+    rect.bottom = rectWindow.bottom - rectWindow.top;
+
+    if (clip > 1)
+    {
+        //only redraw caption
+        GetRgnBox(clip,&rectClip);
 #if 1
-    //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
-    //     with a region that covers the entire window (RealPlayer 7 Update 1)
-    //     As we don't need to clip anything when that occurs, this workaround
-    //     solves the problem.
-    if(rectClip.right == getWindowWidth() && rectClip.bottom == getWindowHeight())
+        //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
+        //     with a region that covers the entire window (RealPlayer 7 Update 1)
+        //     As we don't need to clip anything when that occurs, this workaround
+        //     solves the problem.
+        if(rectClip.right == getWindowWidth() && rectClip.bottom == getWindowHeight())
+        {
+            clip = 0;
+            rectClip = rect;
+        }
+#endif
+    }
+    else
     {
         clip = 0;
         rectClip = rect;
     }
-#endif
-  }
-  else
-  {
-    clip = 0;
-    rectClip = rect;
-  }
-
-  if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
-                      ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
-
-  SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
-
-  if (HAS_BIGFRAME( dwStyle, dwExStyle))
-  {
-    DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
-  }
-  if (HAS_THICKFRAME( dwStyle, dwExStyle ))
-    DrawFrame(hdc, &rect, FALSE, active );
-  else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
-    DrawFrame( hdc, &rect, TRUE, active );
-  else if (HAS_THINFRAME( dwStyle ))
-  {
-    SelectObject( hdc, GetStockObject(NULL_BRUSH) );
-    Rectangle( hdc, 0, 0, rect.right, rect.bottom );
-  }
-
-  if ((dwStyle & WS_CAPTION) == WS_CAPTION)
-  {
-    RECT  r = rect;
-    if (dwExStyle & WS_EX_TOOLWINDOW)
-    {
-      r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
-      rect.top += GetSystemMetrics(SM_CYSMCAPTION);
-    }
+
+    if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
+                         ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
+
+    SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
+
+    if (HAS_BIGFRAME( dwStyle, dwExStyle))
+    {
+        DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
+    }
+    if (HAS_THICKFRAME( dwStyle, dwExStyle ))
+        DrawFrame(hdc, &rect, FALSE, active );
     else
-    {
-      r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
-      rect.top += GetSystemMetrics(SM_CYCAPTION);
-    }
-    if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
-      DrawCaption(hdc,&r,active);
-  }
-
-  if (HAS_MENU())
-  {
-    RECT r = rect;
-    r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
-
-    rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
-  }
-
-  if (dwExStyle & WS_EX_CLIENTEDGE)
-    DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
-
-  if (dwExStyle & WS_EX_STATICEDGE)
-    DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
-
-  /* Draw the scroll-bars */
-  if (dwStyle & WS_VSCROLL)
-    SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
-  if (dwStyle & WS_HSCROLL)
-    SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
-
-  /* Draw the "size-box" */
-  if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
-  {
-    RECT r = rect;
-    r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
-    r.top  = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
-    FillRect( hdc, &r,  GetSysColorBrush(COLOR_SCROLLBAR) );
-    //CB: todo: child windows have sometimes a size grip (i.e. Notepad)
-    //    WS_SIZEBOX isn't set in these cases
-    if (!(dwStyle & WS_CHILD))
-    {
-      POINT p1,p2;
-      HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
-      HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
-      HPEN oldPen = SelectObject(hdc,penDark);
-      INT x;
-
-      p1.x = r.right-1;
-      p1.y = r.bottom;
-      p2.x = r.right;
-      p2.y = r.bottom-1;
-      for (x = 0;x < 3;x++)
-      {
-        SelectObject(hdc,penDark);
-        MoveToEx(hdc,p1.x,p1.y,NULL);
-        LineTo(hdc,p2.x,p2.y);
-        p1.x--;
-        p2.y--;
-        MoveToEx(hdc,p1.x,p1.y,NULL);
-        LineTo(hdc,p2.x,p2.y);
-        SelectObject(hdc,penWhite);
-        p1.x--;
-        p2.y--;
-        MoveToEx(hdc,p1.x,p1.y,NULL);
-        LineTo(hdc,p2.x,p2.y);
-        p1.x -= 2;
-        p2.y -= 2;
-      }
-
-      SelectObject(hdc,oldPen);
-    }
-  }
-
-  ReleaseDC(getWindowHandle(),hdc);
-  IncreaseLogCount();
-  dprintf(("**DoNCPaint %x DONE", getWindowHandle()));
+    if (HAS_DLGFRAME( dwStyle, dwExStyle ))
+        DrawFrame( hdc, &rect, TRUE, active );
+    else
+    if (HAS_THINFRAME( dwStyle ))
+    {
+        SelectObject( hdc, GetStockObject(NULL_BRUSH) );
+        Rectangle( hdc, 0, 0, rect.right, rect.bottom );
+    }
+
+    if ((dwStyle & WS_CAPTION) == WS_CAPTION)
+    {
+        RECT  r = rect;
+        if (dwExStyle & WS_EX_TOOLWINDOW)
+        {
+            r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
+            rect.top += GetSystemMetrics(SM_CYSMCAPTION);
+        }
+        else
+        {
+            r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
+            rect.top += GetSystemMetrics(SM_CYCAPTION);
+        }
+        if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
+            DrawCaption(hdc,&r,active);
+    }
+
+    if (HAS_MENU())
+    {
+        RECT r = rect;
+        r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
+
+        rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
+    }
+
+    if (dwExStyle & WS_EX_CLIENTEDGE)
+        DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
+
+    if (dwExStyle & WS_EX_STATICEDGE)
+        DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
+
+    /* Draw the scroll-bars */
+    if (dwStyle & WS_VSCROLL)
+        SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
+    if (dwStyle & WS_HSCROLL)
+        SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
+
+    /* Draw the "size-box" */
+    if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
+    {
+        RECT r = rect;
+        r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
+        r.top  = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
+        FillRect( hdc, &r,  GetSysColorBrush(COLOR_SCROLLBAR) );
+        //CB: todo: child windows have sometimes a size grip (i.e. Notepad)
+        //    WS_SIZEBOX isn't set in these cases
+        if (!(dwStyle & WS_CHILD))
+        {
+            POINT p1,p2;
+            HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
+            HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
+            HPEN oldPen = SelectObject(hdc,penDark);
+            INT x;
+
+            p1.x = r.right-1;
+            p1.y = r.bottom;
+            p2.x = r.right;
+            p2.y = r.bottom-1;
+            for (x = 0;x < 3;x++)
+            {
+                SelectObject(hdc,penDark);
+                MoveToEx(hdc,p1.x,p1.y,NULL);
+                LineTo(hdc,p2.x,p2.y);
+                p1.x--;
+                p2.y--;
+                MoveToEx(hdc,p1.x,p1.y,NULL);
+                LineTo(hdc,p2.x,p2.y);
+                SelectObject(hdc,penWhite);
+                p1.x--;
+                p2.y--;
+                MoveToEx(hdc,p1.x,p1.y,NULL);
+                LineTo(hdc,p2.x,p2.y);
+                p1.x -= 2;
+                p2.y -= 2;
+            }
+
+            SelectObject(hdc,oldPen);
+        }
+    }
+
+    ReleaseDC(getWindowHandle(),hdc);
+    IncreaseLogCount();
+    dprintf(("**DoNCPaint %x DONE", getWindowHandle()));
 }
 //******************************************************************************
Index: trunk/src/user32/win32wbasepos.cpp
===================================================================
--- trunk/src/user32/win32wbasepos.cpp	(revision 5232)
+++ trunk/src/user32/win32wbasepos.cpp	(revision 5236)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasepos.cpp,v 1.19 2001-02-20 15:40:23 sandervl Exp $ */
+/* $Id: win32wbasepos.cpp,v 1.20 2001-02-21 20:51:07 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (nonclient/position methods)
@@ -227,68 +227,67 @@
 
     if(IsRectEmpty(&windowpos.rcNormalPosition)) {
-    CopyRect(&windowpos.rcNormalPosition, &rectWindow);
+        CopyRect(&windowpos.rcNormalPosition, &rectWindow);
     }
     if(!HOOK_CallHooksA(WH_CBT, HCBT_MINMAX, getWindowHandle(), cmd))
     {
-    if(getStyle() & WS_MINIMIZE )
-    {
-        if(!SendInternalMessageA(WM_QUERYOPEN, 0, 0L))
-        return (SWP_NOSIZE | SWP_NOMOVE);
-    }
-    switch( cmd )
-    {
+        if(getStyle() & WS_MINIMIZE )
+        {
+            if(!SendInternalMessageA(WM_QUERYOPEN, 0, 0L))
+                return (SWP_NOSIZE | SWP_NOMOVE);
+        }
+        switch( cmd )
+        {
         case SW_MINIMIZE:
-        if( getStyle() & WS_MAXIMIZE)
-        {
-                setFlags(getFlags() | WIN_RESTORE_MAX);
-                setStyle(getStyle() & ~WS_MAXIMIZE);
-                }
-                else    setFlags(getFlags() & ~WIN_RESTORE_MAX);
-
-        setStyle(getStyle() | WS_MINIMIZE);
-
-        SetRect(lpRect, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
-                GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
-        break;
+            if( getStyle() & WS_MAXIMIZE)
+            {
+                 setFlags(getFlags() | WIN_RESTORE_MAX);
+                 setStyle(getStyle() & ~WS_MAXIMIZE);
+            }
+            else setFlags(getFlags() & ~WIN_RESTORE_MAX);
+
+            setStyle(getStyle() | WS_MINIMIZE);
+
+            SetRect(lpRect, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
+                    GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
+            break;
 
         case SW_MAXIMIZE:
-                GetMinMaxInfo(&size, &windowpos.ptMaxPosition, NULL, NULL );
-
-        if(getStyle() & WS_MINIMIZE )
-        {
-             setStyle(getStyle() & ~WS_MINIMIZE);
-        }
-                setStyle(getStyle() | WS_MAXIMIZE);
-
-        SetRect(lpRect, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
-                size.x, size.y );
-        break;
+            GetMinMaxInfo(&size, &windowpos.ptMaxPosition, NULL, NULL );
+
+            if(getStyle() & WS_MINIMIZE )
+            {
+                 setStyle(getStyle() & ~WS_MINIMIZE);
+            }
+            setStyle(getStyle() | WS_MAXIMIZE);
+
+            SetRect(lpRect, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
+                    size.x, size.y );
+            break;
 
         case SW_RESTORE:
-        if(getStyle() & WS_MINIMIZE)
-        {
+            if(getStyle() & WS_MINIMIZE)
+            {
                 setStyle(getStyle() & ~WS_MINIMIZE);
 
                 if( getFlags() & WIN_RESTORE_MAX)
                 {
-                /* Restore to maximized position */
-                            GetMinMaxInfo(&size, &windowpos.ptMaxPosition, NULL, NULL);
-                setStyle(getStyle() | WS_MAXIMIZE);
-                SetRect(lpRect, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y, size.x, size.y);
-                break;
+                    /* Restore to maximized position */
+                    GetMinMaxInfo(&size, &windowpos.ptMaxPosition, NULL, NULL);
+                    setStyle(getStyle() | WS_MAXIMIZE);
+                    SetRect(lpRect, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y, size.x, size.y);
+                    break;
                 }
-        }
-        else
+            }
+            else
             if( !(getStyle() & WS_MAXIMIZE) )
-            return 0;
-            else    setStyle(getStyle() & ~WS_MAXIMIZE);
-
-        /* Restore to normal position */
-
-        *lpRect = windowpos.rcNormalPosition;
-        lpRect->right -= lpRect->left;
-        lpRect->bottom -= lpRect->top;
-        break;
-    }
+                 return 0;
+            else setStyle(getStyle() & ~WS_MAXIMIZE);
+
+            /* Restore to normal position */
+            *lpRect = windowpos.rcNormalPosition;
+            lpRect->right -= lpRect->left;
+            lpRect->bottom -= lpRect->top;
+            break;
+        }
     }
     else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
