Minimize window via style change

Sebastian Reichelt SebastianR at
Fri Sep 22 21:49:05 CDT 2006


In a program I use (downloadable from, I
encountered a problem with automatic minimizing of a window. I will try
to describe it in detail because my patch may not be the best way to
fix it.

Minimizing, maximizing and restoring a window is possible not only by
using the ShowWindow function, but also manually by setting the window
style with SetWindowLong and calling SetWindowPos with the
SWP_FRAMECHANGED flag set. Therefore SetWindowPos needs to update the
iconic state if SWP_FRAMECHANGED is set. I am not sure if any special
action is required for maximizing.

The PokerStars program uses this method of minimizing a window when you
click on "Go to Table". With the version of WINE in Debian testing, the
lobby window is not minimized but becomes really small instead, since
the size specified in the SetWindowPos call is 32x32.

The attached patch works for this program, but may not be 100% correct.
If I just call X11DRV_set_iconic_state, something that happens later in
SetWindowPos causes the window to be brought up again. Therefore I
added a return statement, which might cause unexpected problems.

Since ShowWindow calls SetWindowPos, the X11DRV_set_iconic_state
function is executed twice from ShowWindow now. I wonder if it is
possible (or even necessary) to move the entire minimize/maximize logic
into SetWindowPos. Maybe the ShowWindow function can even be
implemented completely outside of the X11 driver then.

Hopefully this information is enough; thanks for reading this.
Anyway, this is my changelog entry, the patch (to WINE 0.9.15 from
Debian testing) is attached:

2006-09-23  Sebastian Reichelt <SebastianR at>

        * dlls/x11drv/winpos.c:
        X11DRV_SetWindowPos: Minimize/restore window according to
        window style.

Sebastian Reichelt

-------------- next part --------------
--- dlls/x11drv/winpos.c.old	2006-09-23 01:55:20.000000000 +0200
+++ dlls/x11drv/winpos.c	2006-09-23 03:14:28.000000000 +0200
@@ -708,6 +708,14 @@
         else if (winpos->cy > 32767) winpos->cy = 32767;
+    if (winpos->flags & SWP_FRAMECHANGED)
+    {
+        DWORD style = GetWindowLongW( winpos->hwnd, GWL_STYLE );
+        X11DRV_set_iconic_state( winpos->hwnd );
+        if (style & WS_MINIMIZE)
+            return TRUE;
+    }
     if (!SWP_DoWinPosChanging( winpos, &newWindowRect, &newClientRect )) return FALSE;
     /* Fix redundant flags */

More information about the wine-patches mailing list