Alexandre Julliard : user32: Make child windows inherit the WS_EX_LAYOUTRTL style from their parent.

Alexandre Julliard julliard at winehq.org
Thu Sep 2 12:01:25 CDT 2010


Module: wine
Branch: master
Commit: 942866f90d511234e767dfb2e3374216b0f66a65
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=942866f90d511234e767dfb2e3374216b0f66a65

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Sep  2 15:46:43 2010 +0200

user32: Make child windows inherit the WS_EX_LAYOUTRTL style from their parent.

---

 dlls/user32/tests/win.c |   32 ++++++++++++++++++++++++++++++++
 dlls/user32/win.c       |    6 ++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index b9966e7..057e3fc 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -53,6 +53,8 @@ static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
 static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
 static int  (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
 static BOOL (WINAPI *pGetGUIThreadInfo)(DWORD, GUITHREADINFO*);
+static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
+static DWORD (WINAPI *pGetLayout)(HDC hdc);
 
 static BOOL test_lbuttondown_flag;
 static HWND hwndMessage;
@@ -4829,6 +4831,33 @@ static void test_CreateWindow(void)
     ok( rc.bottom <= expected_cy, "invalid rect bottom %u\n", rc.bottom );
     DestroyWindow(hwnd);
 
+    if (pGetLayout && pSetLayout)
+    {
+        HDC hdc = GetDC( parent );
+        pSetLayout( hdc, LAYOUT_RTL );
+        if (pGetLayout( hdc ))
+        {
+            ReleaseDC( parent, hdc );
+            DestroyWindow( parent );
+            SetLastError( 0xdeadbeef );
+            parent = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP,
+                                    0, 0, 100, 100, 0, 0, 0, NULL);
+            ok( parent != 0, "creation failed err %u\n", GetLastError());
+            expect_ex_style( parent, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL );
+            hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL);
+            ok( hwnd != 0, "creation failed err %u\n", GetLastError());
+            expect_ex_style( hwnd, WS_EX_LAYOUTRTL );
+            DestroyWindow( hwnd );
+            SetWindowLongW( parent, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT );
+            hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL);
+            ok( hwnd != 0, "creation failed err %u\n", GetLastError());
+            expect_ex_style( hwnd, 0 );
+            DestroyWindow( hwnd );
+        }
+        else win_skip( "SetLayout not supported\n" );
+    }
+    else win_skip( "SetLayout not available\n" );
+
     DestroyWindow(parent);
 
     UnregisterClass("MinMax_WndClass", GetModuleHandle(0));
@@ -6047,6 +6076,7 @@ static void test_winregion(void)
 START_TEST(win)
 {
     HMODULE user32 = GetModuleHandleA( "user32.dll" );
+    HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
     pGetAncestor = (void *)GetProcAddress( user32, "GetAncestor" );
     pGetWindowInfo = (void *)GetProcAddress( user32, "GetWindowInfo" );
     pGetWindowModuleFileNameA = (void *)GetProcAddress( user32, "GetWindowModuleFileNameA" );
@@ -6056,6 +6086,8 @@ START_TEST(win)
     pMonitorFromPoint = (void *)GetProcAddress( user32,  "MonitorFromPoint" );
     pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
     pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
+    pGetLayout = (void *)GetProcAddress( gdi32, "GetLayout" );
+    pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" );
 
     if (!RegisterWindowClasses()) assert(0);
 
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 6082b80..e03ce46 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -1178,6 +1178,12 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
             parent = GetDesktopWindow();
             owner = cs->hwndParent;
         }
+        else
+        {
+            DWORD parent_style = GetWindowLongW( parent, GWL_EXSTYLE );
+            if ((parent_style & WS_EX_LAYOUTRTL) && !(parent_style & WS_EX_NOINHERITLAYOUT))
+                cs->dwExStyle |= WS_EX_LAYOUTRTL;
+        }
     }
     else
     {




More information about the wine-cvs mailing list