Alexandre Julliard : user32: Set the default process layout based on the file description in the version resource .
Alexandre Julliard
julliard at winehq.org
Fri Sep 24 11:43:45 CDT 2010
Module: wine
Branch: master
Commit: ddaea5456edf7df5ef1a04cf6c8bbcd05247827d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ddaea5456edf7df5ef1a04cf6c8bbcd05247827d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Sep 24 15:20:52 2010 +0200
user32: Set the default process layout based on the file description in the version resource.
---
dlls/user32/Makefile.in | 2 +-
dlls/user32/win.c | 42 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/Makefile.in b/dlls/user32/Makefile.in
index acd827b..e37f536 100644
--- a/dlls/user32/Makefile.in
+++ b/dlls/user32/Makefile.in
@@ -1,7 +1,7 @@
EXTRADEFS = -D_USER32_ -D_WINABLE_
MODULE = user32.dll
IMPORTLIB = user32
-IMPORTS = gdi32 advapi32
+IMPORTS = gdi32 version advapi32
DELAYIMPORTS = imm32
C_SRCS = \
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index b847a44..ee44278 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -27,6 +27,7 @@
#include <string.h>
#include "windef.h"
#include "winbase.h"
+#include "winver.h"
#include "wine/server.h"
#include "wine/unicode.h"
#include "win.h"
@@ -40,7 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(win);
#define NB_USER_HANDLES ((LAST_USER_HANDLE - FIRST_USER_HANDLE + 1) >> 1)
#define USER_HANDLE_TO_INDEX(hwnd) ((LOWORD(hwnd) - FIRST_USER_HANDLE) >> 1)
-static DWORD process_layout;
+static DWORD process_layout = ~0u;
/**********************************************************************/
@@ -1254,8 +1255,10 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
if (className != (LPCWSTR)DESKTOP_CLASS_ATOM &&
(IS_INTRESOURCE(className) || strcmpiW( className, messageW )))
{
+ DWORD layout;
+ GetProcessDefaultLayout( &layout );
+ if (layout & LAYOUT_RTL) cs->dwExStyle |= WS_EX_LAYOUTRTL;
parent = GetDesktopWindow();
- if (process_layout & LAYOUT_RTL) cs->dwExStyle |= WS_EX_LAYOUTRTL;
}
}
@@ -3552,6 +3555,41 @@ BOOL WINAPI GetProcessDefaultLayout( DWORD *layout )
SetLastError( ERROR_NOACCESS );
return FALSE;
}
+ if (process_layout == ~0u)
+ {
+ static const WCHAR translationW[] = { '\\','V','a','r','F','i','l','e','I','n','f','o',
+ '\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
+ static const WCHAR filedescW[] = { '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
+ '\\','%','0','4','x','%','0','4','x',
+ '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0 };
+ WCHAR *str, buffer[MAX_PATH];
+ DWORD i, len, version_layout = 0;
+ DWORD user_lang = GetUserDefaultLangID();
+ DWORD *languages;
+ void *data = NULL;
+
+ GetModuleFileNameW( 0, buffer, MAX_PATH );
+ if (!(len = GetFileVersionInfoSizeW( buffer, NULL ))) goto done;
+ if (!(data = HeapAlloc( GetProcessHeap(), 0, len ))) goto done;
+ if (!GetFileVersionInfoW( buffer, 0, len, data )) goto done;
+ if (!VerQueryValueW( data, translationW, (void **)&languages, &len ) || !len) goto done;
+
+ len /= sizeof(DWORD);
+ for (i = 0; i < len; i++) if (LOWORD(languages[i]) == user_lang) break;
+ if (i == len) /* try neutral language */
+ for (i = 0; i < len; i++)
+ if (LOWORD(languages[i]) == MAKELANGID( PRIMARYLANGID(user_lang), SUBLANG_NEUTRAL )) break;
+ if (i == len) i = 0; /* default to the first one */
+
+ sprintfW( buffer, filedescW, LOWORD(languages[i]), HIWORD(languages[i]) );
+ if (!VerQueryValueW( data, buffer, (void **)&str, &len )) goto done;
+ TRACE( "found description %s\n", debugstr_w( str ));
+ if (str[0] == 0x200e && str[1] == 0x200e) version_layout = LAYOUT_RTL;
+
+ done:
+ HeapFree( GetProcessHeap(), 0, data );
+ process_layout = version_layout;
+ }
*layout = process_layout;
return TRUE;
}
More information about the wine-cvs
mailing list