Author: fireball
Date: Wed May 3 14:35:11 2006
New Revision: 21780
URL:
http://svn.reactos.ru/svn/reactos?rev=21780&view=rev
Log:
- Bug 1451: Patch by Thomas Weidenmueller:
System controls, such as comboboxes and listboxes are always unicode, even when
created with CreateWindowExA. Therefore, ansi messages need to be converted to
unicode and vice versa when sent to these windows. This patch fixes some(!) of these
issues! Not all control messages are handled!
Modified:
trunk/reactos/dll/win32/user32/windows/message.c
trunk/reactos/subsystems/win32/win32k/ntuser/message.c
Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/windows/me…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c Wed May 3 14:35:11 2006
@@ -414,9 +414,44 @@
case LB_ADDFILE:
case EM_REPLACESEL:
{
- UNICODE_STRING UnicodeString;
- RtlCreateUnicodeStringFromAsciiz(&UnicodeString, (LPSTR)AnsiMsg->lParam);
- UnicodeMsg->lParam = (LPARAM)UnicodeString.Buffer;
+ goto ConvertLParamString;
+ }
+
+ case LB_ADDSTRING:
+ case LB_ADDSTRING_LOWER:
+ case LB_ADDSTRING_UPPER:
+ case LB_INSERTSTRING:
+ case LB_INSERTSTRING_UPPER:
+ case LB_INSERTSTRING_LOWER:
+ case LB_FINDSTRING:
+ case LB_FINDSTRINGEXACT:
+ case LB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & LBS_HASSTRINGS))
+ {
+ goto ConvertLParamString;
+ }
+ break;
+ }
+
+ case CB_ADDSTRING:
+ case CB_INSERTSTRING:
+ case CB_FINDSTRING:
+ case CB_FINDSTRINGEXACT:
+ case CB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & CBS_HASSTRINGS))
+ {
+ UNICODE_STRING UnicodeString;
+
+ConvertLParamString:
+ RtlCreateUnicodeStringFromAsciiz(&UnicodeString,
(LPSTR)AnsiMsg->lParam);
+ UnicodeMsg->lParam = (LPARAM)UnicodeString.Buffer;
+ }
break;
}
@@ -501,11 +536,47 @@
case LB_ADDFILE:
case EM_REPLACESEL:
{
- UNICODE_STRING UnicodeString;
- RtlInitUnicodeString(&UnicodeString, (PCWSTR)UnicodeMsg->lParam);
- RtlFreeUnicodeString(&UnicodeString);
- break;
+ goto FreeLParamString;
}
+
+ case LB_ADDSTRING:
+ case LB_ADDSTRING_LOWER:
+ case LB_ADDSTRING_UPPER:
+ case LB_INSERTSTRING:
+ case LB_INSERTSTRING_UPPER:
+ case LB_INSERTSTRING_LOWER:
+ case LB_FINDSTRING:
+ case LB_FINDSTRINGEXACT:
+ case LB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & LBS_HASSTRINGS))
+ {
+ goto FreeLParamString;
+ }
+ break;
+ }
+
+ case CB_ADDSTRING:
+ case CB_INSERTSTRING:
+ case CB_FINDSTRING:
+ case CB_FINDSTRINGEXACT:
+ case CB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & CBS_HASSTRINGS))
+ {
+ UNICODE_STRING UnicodeString;
+
+FreeLParamString:
+ RtlInitUnicodeString(&UnicodeString, (PCWSTR)UnicodeMsg->lParam);
+ RtlFreeUnicodeString(&UnicodeString);
+ }
+ break;
+ }
+
case WM_NCCREATE:
case WM_CREATE:
@@ -640,20 +711,58 @@
break;
}
case WM_SETTEXT:
- {
- ANSI_STRING AnsiString;
- UNICODE_STRING UnicodeString;
- RtlInitUnicodeString(&UnicodeString, (PWSTR) UnicodeMsg->lParam);
- if (! NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiString,
- &UnicodeString,
- TRUE)))
- {
- return FALSE;
- }
- AnsiMsg->lParam = (LPARAM) AnsiString.Buffer;
+ case CB_DIR:
+ case LB_DIR:
+ case LB_ADDFILE:
+ {
+ goto ConvertLParamString;
+ }
+
+ case LB_ADDSTRING:
+ case LB_ADDSTRING_LOWER:
+ case LB_ADDSTRING_UPPER:
+ case LB_INSERTSTRING:
+ case LB_INSERTSTRING_UPPER:
+ case LB_INSERTSTRING_LOWER:
+ case LB_FINDSTRING:
+ case LB_FINDSTRINGEXACT:
+ case LB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & LBS_HASSTRINGS))
+ {
+ goto ConvertLParamString;
+ }
break;
- }
- }
+ }
+
+ case CB_ADDSTRING:
+ case CB_INSERTSTRING:
+ case CB_FINDSTRING:
+ case CB_FINDSTRINGEXACT:
+ case CB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & CBS_HASSTRINGS))
+ {
+ ANSI_STRING AnsiString;
+ UNICODE_STRING UnicodeString;
+
+ConvertLParamString:
+ RtlInitUnicodeString(&UnicodeString, (PWSTR) UnicodeMsg->lParam);
+ if (! NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiString,
+ &UnicodeString,
+ TRUE)))
+ {
+ return FALSE;
+ }
+ AnsiMsg->lParam = (LPARAM) AnsiString.Buffer;
+ }
+ break;
+ }
+ }
return TRUE;
}
@@ -671,10 +780,7 @@
}
case WM_SETTEXT:
{
- ANSI_STRING AString;
- RtlInitAnsiString(&AString, (PSTR) AnsiMsg->lParam);
- RtlFreeAnsiString(&AString);
- break;
+ goto FreeLParamString;
}
case WM_CREATE:
case WM_NCCREATE:
@@ -693,6 +799,45 @@
RtlFreeHeap(GetProcessHeap(), 0, Cs);
break;
}
+
+ case LB_ADDSTRING:
+ case LB_ADDSTRING_LOWER:
+ case LB_ADDSTRING_UPPER:
+ case LB_INSERTSTRING:
+ case LB_INSERTSTRING_UPPER:
+ case LB_INSERTSTRING_LOWER:
+ case LB_FINDSTRING:
+ case LB_FINDSTRINGEXACT:
+ case LB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & LBS_HASSTRINGS))
+ {
+ goto FreeLParamString;
+ }
+ break;
+ }
+
+ case CB_ADDSTRING:
+ case CB_INSERTSTRING:
+ case CB_FINDSTRING:
+ case CB_FINDSTRINGEXACT:
+ case CB_SELECTSTRING:
+ {
+ DWORD dwStyle = GetWindowLongW(AnsiMsg->hwnd, GWL_STYLE);
+ if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) &&
+ (dwStyle & CBS_HASSTRINGS))
+ {
+ ANSI_STRING AString;
+
+FreeLParamString:
+ RtlInitAnsiString(&AString, (PSTR) AnsiMsg->lParam);
+ RtlFreeAnsiString(&AString);
+ }
+ break;
+ }
+
}
return TRUE;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c Wed May 3 14:35:11 2006
@@ -379,11 +379,15 @@
MsgInfo.HandledByKernel = FALSE;
Result = 0;
- MsgInfo.Ansi = !Window->Unicode;
if (Window->IsSystem)
- MsgInfo.Proc = (Window->Unicode ? Window->WndProc :
Window->WndProcExtra);
+ {
+ MsgInfo.Proc = (!MsgInfo.Ansi ? Window->WndProc :
Window->WndProcExtra);
+ }
else
+ {
+ MsgInfo.Ansi = !Window->Unicode;
MsgInfo.Proc = Window->WndProc;
+ }
}
}
}
@@ -1565,11 +1569,15 @@
Info.Ansi = ! Window->Unicode;
}
- Info.Ansi = !Window->Unicode;
if (Window->IsSystem)
- Info.Proc = (Window->Unicode ? Window->WndProc :
Window->WndProcExtra);
+ {
+ Info.Proc = (!Info.Ansi ? Window->WndProc : Window->WndProcExtra);
+ }
else
+ {
+ Info.Ansi = !Window->Unicode;
Info.Proc = Window->WndProc;
+ }
}
else
{