Commit 8f565eb6 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

user32: Add more window style tests, make them pass under Wine.

parent 0652bbc3
...@@ -3696,6 +3696,7 @@ static void register_style_check_class(void) ...@@ -3696,6 +3696,7 @@ static void register_style_check_class(void)
}; };
atomStyleCheckClass = RegisterClass(&wc); atomStyleCheckClass = RegisterClass(&wc);
assert(atomStyleCheckClass);
} }
static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut) static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut)
...@@ -3723,12 +3724,23 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle ...@@ -3723,12 +3724,23 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle
dwActualStyle = GetWindowLong(hwnd, GWL_STYLE); dwActualStyle = GetWindowLong(hwnd, GWL_STYLE);
dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE); dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
ok((dwActualStyle == dwStyleOut) && (dwActualExStyle == dwExStyleOut), ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle);
"Style (0x%08x) should really be 0x%08x and/or Ex style (0x%08x) should really be 0x%08x\n", ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
dwActualStyle, dwStyleOut, dwActualExStyle, dwExStyleOut);
/* try setting the styles explicitly */ /* try setting the styles explicitly */
SetWindowLong( hwnd, GWL_EXSTYLE, dwExStyleIn ); SetWindowLong( hwnd, GWL_EXSTYLE, dwExStyleIn );
dwActualStyle = GetWindowLong(hwnd, GWL_STYLE);
dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
/* WS_EX_WINDOWEDGE can't always be changed */
if (dwExStyleIn & WS_EX_DLGMODALFRAME)
dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
else if ((dwActualStyle & (WS_DLGFRAME | WS_THICKFRAME)) && !(dwExStyleIn & WS_EX_STATICEDGE))
dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
else
dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE;
ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle);
ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
SetWindowLong( hwnd, GWL_STYLE, dwStyleIn ); SetWindowLong( hwnd, GWL_STYLE, dwStyleIn );
dwActualStyle = GetWindowLong(hwnd, GWL_STYLE); dwActualStyle = GetWindowLong(hwnd, GWL_STYLE);
dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE); dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
...@@ -3736,15 +3748,18 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle ...@@ -3736,15 +3748,18 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle
if ((dwStyleIn & (WS_CHILD|WS_POPUP)) == WS_CHILD) dwStyleOut = dwStyleIn; if ((dwStyleIn & (WS_CHILD|WS_POPUP)) == WS_CHILD) dwStyleOut = dwStyleIn;
else dwStyleOut = dwStyleIn | WS_CLIPSIBLINGS; else dwStyleOut = dwStyleIn | WS_CLIPSIBLINGS;
/* WS_EX_WINDOWEDGE can't always be changed */ /* WS_EX_WINDOWEDGE can't always be changed */
if ((dwExStyleIn & WS_EX_DLGMODALFRAME) || (dwStyleIn & WS_THICKFRAME)) if (dwExStyleIn & WS_EX_DLGMODALFRAME)
dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE; dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
else if (dwStyleIn & (WS_CHILD | WS_POPUP)) else if ((dwActualStyle & (WS_DLGFRAME | WS_THICKFRAME)) && !(dwExStyleIn & WS_EX_STATICEDGE))
dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
else
dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE; dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE;
ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle);
/* FIXME: Remove the condition below once Wine is fixed */
if (dwActualExStyle != dwExStyleOut)
todo_wine ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
else else
dwExStyleOut = dwExStyleIn; ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
ok((dwActualStyle == dwStyleOut) && (dwActualExStyle == dwExStyleOut),
"%08x/%08x: Style (0x%08x) should really be 0x%08x and/or Ex style (0x%08x) should really be 0x%08x\n",
dwStyleIn, dwExStyleIn, dwActualStyle, dwStyleOut, dwActualExStyle, dwExStyleOut);
DestroyWindow(hwnd); DestroyWindow(hwnd);
if (hwndParent) DestroyWindow(hwndParent); if (hwndParent) DestroyWindow(hwndParent);
...@@ -3756,17 +3771,36 @@ static void test_window_styles(void) ...@@ -3756,17 +3771,36 @@ static void test_window_styles(void)
register_style_check_class(); register_style_check_class();
check_window_style(0, 0, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE); check_window_style(0, 0, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE);
check_window_style(WS_DLGFRAME, 0, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE);
check_window_style(WS_THICKFRAME, 0, WS_THICKFRAME|WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE);
check_window_style(WS_DLGFRAME, WS_EX_STATICEDGE, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE|WS_EX_STATICEDGE);
check_window_style(WS_THICKFRAME, WS_EX_STATICEDGE, WS_THICKFRAME|WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE|WS_EX_STATICEDGE);
check_window_style(WS_OVERLAPPEDWINDOW, 0, WS_CLIPSIBLINGS|WS_OVERLAPPEDWINDOW, WS_EX_WINDOWEDGE); check_window_style(WS_OVERLAPPEDWINDOW, 0, WS_CLIPSIBLINGS|WS_OVERLAPPEDWINDOW, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD, 0, WS_CHILD, 0); check_window_style(WS_CHILD, 0, WS_CHILD, 0);
check_window_style(WS_CHILD|WS_DLGFRAME, 0, WS_CHILD|WS_DLGFRAME, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD|WS_THICKFRAME, 0, WS_CHILD|WS_THICKFRAME, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD|WS_DLGFRAME, WS_EX_STATICEDGE, WS_CHILD|WS_DLGFRAME, WS_EX_STATICEDGE);
check_window_style(WS_CHILD|WS_THICKFRAME, WS_EX_STATICEDGE, WS_CHILD|WS_THICKFRAME, WS_EX_STATICEDGE);
check_window_style(WS_CHILD|WS_CAPTION, 0, WS_CHILD|WS_CAPTION, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD|WS_CAPTION|WS_SYSMENU, 0, WS_CHILD|WS_CAPTION|WS_SYSMENU, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD, WS_EX_WINDOWEDGE, WS_CHILD, 0);
check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME, WS_CHILD, WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME);
check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME|WS_EX_STATICEDGE, WS_CHILD, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME);
check_window_style(WS_CHILD|WS_POPUP, 0, WS_CHILD|WS_POPUP|WS_CLIPSIBLINGS, 0); check_window_style(WS_CHILD|WS_POPUP, 0, WS_CHILD|WS_POPUP|WS_CLIPSIBLINGS, 0);
check_window_style(WS_CHILD|WS_POPUP|WS_DLGFRAME, 0, WS_CHILD|WS_POPUP|WS_DLGFRAME|WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD|WS_POPUP|WS_THICKFRAME, 0, WS_CHILD|WS_POPUP|WS_THICKFRAME|WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD|WS_POPUP|WS_DLGFRAME, WS_EX_STATICEDGE, WS_CHILD|WS_POPUP|WS_DLGFRAME|WS_CLIPSIBLINGS, WS_EX_STATICEDGE);
check_window_style(WS_CHILD|WS_POPUP|WS_THICKFRAME, WS_EX_STATICEDGE, WS_CHILD|WS_POPUP|WS_THICKFRAME|WS_CLIPSIBLINGS, WS_EX_STATICEDGE);
check_window_style(WS_CHILD|WS_POPUP, WS_EX_APPWINDOW, WS_CHILD|WS_POPUP|WS_CLIPSIBLINGS, WS_EX_APPWINDOW); check_window_style(WS_CHILD|WS_POPUP, WS_EX_APPWINDOW, WS_CHILD|WS_POPUP|WS_CLIPSIBLINGS, WS_EX_APPWINDOW);
check_window_style(WS_CHILD|WS_POPUP, WS_EX_WINDOWEDGE, WS_CHILD|WS_POPUP|WS_CLIPSIBLINGS, 0); check_window_style(WS_CHILD|WS_POPUP, WS_EX_WINDOWEDGE, WS_CHILD|WS_POPUP|WS_CLIPSIBLINGS, 0);
check_window_style(WS_CHILD, WS_EX_WINDOWEDGE, WS_CHILD, 0); check_window_style(WS_CHILD, WS_EX_WINDOWEDGE, WS_CHILD, 0);
check_window_style(0, WS_EX_TOOLWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW); check_window_style(0, WS_EX_TOOLWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW);
check_window_style(WS_POPUP, 0, WS_POPUP|WS_CLIPSIBLINGS, 0); check_window_style(WS_POPUP, 0, WS_POPUP|WS_CLIPSIBLINGS, 0);
check_window_style(WS_POPUP, WS_EX_WINDOWEDGE, WS_POPUP|WS_CLIPSIBLINGS, 0); check_window_style(WS_POPUP, WS_EX_WINDOWEDGE, WS_POPUP|WS_CLIPSIBLINGS, 0);
check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME, WS_CHILD, WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME); check_window_style(WS_POPUP|WS_DLGFRAME, 0, WS_POPUP|WS_DLGFRAME|WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME|WS_EX_STATICEDGE, WS_CHILD, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME); check_window_style(WS_POPUP|WS_THICKFRAME, 0, WS_POPUP|WS_THICKFRAME|WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
check_window_style(WS_POPUP|WS_DLGFRAME, WS_EX_STATICEDGE, WS_POPUP|WS_DLGFRAME|WS_CLIPSIBLINGS, WS_EX_STATICEDGE);
check_window_style(WS_POPUP|WS_THICKFRAME, WS_EX_STATICEDGE, WS_POPUP|WS_THICKFRAME|WS_CLIPSIBLINGS, WS_EX_STATICEDGE);
check_window_style(WS_CAPTION, WS_EX_STATICEDGE, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE); check_window_style(WS_CAPTION, WS_EX_STATICEDGE, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE);
check_window_style(0, WS_EX_APPWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE); check_window_style(0, WS_EX_APPWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE);
......
...@@ -1324,14 +1324,15 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, ...@@ -1324,14 +1324,15 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
wndPtr->dwStyle |= WS_CAPTION; wndPtr->dwStyle |= WS_CAPTION;
} }
/* /* WS_EX_WINDOWEDGE depends on some other styles */
* WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
* why does the user get to set it?
*/
if ((wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) ||
(wndPtr->dwStyle & (WS_DLGFRAME | WS_THICKFRAME)))
wndPtr->dwExStyle |= WS_EX_WINDOWEDGE; wndPtr->dwExStyle |= WS_EX_WINDOWEDGE;
else if (wndPtr->dwStyle & (WS_DLGFRAME | WS_THICKFRAME))
{
if (!((wndPtr->dwExStyle & WS_EX_STATICEDGE) &&
(wndPtr->dwStyle & (WS_CHILD | WS_POPUP))))
wndPtr->dwExStyle |= WS_EX_WINDOWEDGE;
}
else else
wndPtr->dwExStyle &= ~WS_EX_WINDOWEDGE; wndPtr->dwExStyle &= ~WS_EX_WINDOWEDGE;
...@@ -2176,6 +2177,8 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B ...@@ -2176,6 +2177,8 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B
newval = style.styleNew; newval = style.styleNew;
/* WS_CLIPSIBLINGS can't be reset on top-level windows */ /* WS_CLIPSIBLINGS can't be reset on top-level windows */
if (wndPtr->parent == GetDesktopWindow()) newval |= WS_CLIPSIBLINGS; if (wndPtr->parent == GetDesktopWindow()) newval |= WS_CLIPSIBLINGS;
/* FIXME: changing WS_DLGFRAME | WS_THICKFRAME is supposed to change
WS_EX_WINDOWEDGE too */
break; break;
case GWL_EXSTYLE: case GWL_EXSTYLE:
style.styleOld = wndPtr->dwExStyle; style.styleOld = wndPtr->dwExStyle;
...@@ -2186,9 +2189,11 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B ...@@ -2186,9 +2189,11 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B
/* WS_EX_TOPMOST can only be changed through SetWindowPos */ /* WS_EX_TOPMOST can only be changed through SetWindowPos */
newval = (style.styleNew & ~WS_EX_TOPMOST) | (wndPtr->dwExStyle & WS_EX_TOPMOST); newval = (style.styleNew & ~WS_EX_TOPMOST) | (wndPtr->dwExStyle & WS_EX_TOPMOST);
/* WS_EX_WINDOWEDGE depends on some other styles */ /* WS_EX_WINDOWEDGE depends on some other styles */
if ((newval & WS_EX_DLGMODALFRAME) || (wndPtr->dwStyle & WS_THICKFRAME)) if (newval & WS_EX_DLGMODALFRAME)
newval |= WS_EX_WINDOWEDGE;
else if (!(newval & WS_EX_STATICEDGE) && (wndPtr->dwStyle & (WS_DLGFRAME | WS_THICKFRAME)))
newval |= WS_EX_WINDOWEDGE; newval |= WS_EX_WINDOWEDGE;
else if (wndPtr->dwStyle & (WS_CHILD|WS_POPUP)) else
newval &= ~WS_EX_WINDOWEDGE; newval &= ~WS_EX_WINDOWEDGE;
break; break;
case GWLP_HWNDPARENT: case GWLP_HWNDPARENT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment