Allow exchanging of WS_CHILD and WS_POPUP in SetWindowLong()

Dmitry Timoshkov dmitry at sloboda.ru
Fri Mar 16 08:39:05 CST 2001


Hello.

According to the documentation for SetParent():
"For compatibility reasons, SetParent does not modify the WS_CHILD or WS_POPUP
window styles of the window whose parent is being changed. Therefore, if
hWndNewParent is NULL, you should also clear the WS_CHILD bit and set
the WS_POPUP style after calling SetParent. Conversely, if hWndNewParent
is not NULL and the window was previously a child of the desktop, you should
clear the WS_POPUP style and set the WS_CHILD style before calling SetParent."

This patch helps to continue yet another InstallShield installer, which does:

GWL_STYLE == 0xfffffff0
#define WS_POPUP         0x80000000L
#define WS_CHILD         0x40000000L
#define DS_MODALFRAME    0x0080

Call user32.335: GetWindowLongA(00000708,fffffff0) ret=00406020 fs=008f
Ret  user32.335: GetWindowLongA() retval=840000c8 ret=00406020 fs=008f
Call user32.571: SetWindowLongA(00000708,fffffff0,40000048) ret=00406036 fs=008f
...
Call user32.545: SetParent(00000708,00000138) ret=00406057 fs=008f

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Allow exchanging of WS_CHILD and WS_POPUP in SetWindowLong().

--- cvs/wine/windows/win.c	Mon Feb 12 11:40:42 2001
+++ wine/windows/win.c	Fri Mar 16 22:04:58 2001
@@ -2031,8 +2031,25 @@
 		goto end;
 	case GWL_STYLE:
 	       	style.styleOld = wndPtr->dwStyle;
-		newval &= ~(WS_CHILD);	/* this bit can't be changed this way */
-		style.styleNew = newval | (style.styleOld & (WS_CHILD));
+		/* WS_CHILD and WS_POPUP can be exchanged according
+		   to the documentation for SetParent() */
+		if((style.styleOld & WS_CHILD) && !(newval & WS_CHILD))
+		{
+		    if(!(newval & WS_POPUP))
+		    {
+			ERR("Removing WS_CHILD without replacing it by WS_POPUP is not allowed!\n");
+			newval |= WS_CHILD;
+		    }
+		}
+		if((style.styleOld & WS_POPUP) && !(newval & WS_POPUP))
+		{
+		    if(!(newval & WS_CHILD))
+		    {
+			ERR("Removing WS_POPUP without replacing it by WS_CHILD is not allowed!\n");
+			newval |= WS_POPUP;
+		    }
+		}
+		style.styleNew = newval;
 
 		if (wndPtr->flags & WIN_ISWIN32)
 			SendMessageA(hwnd,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);






More information about the wine-patches mailing list