Commit in reactos/lib/user32/windows on MAIN
message.c+16-191.42 -> 1.43
- Return value of WM_GETTEXTLENGTH is in TCHARs, not in bytes, so there is
  no need to convert between Ansi and Unicode (number of characters remains
  the same)
- Allocate Ansi buffer for WM_GETTEXT since MultiByteToWideChar can't handle
  overlapping buffers

reactos/lib/user32/windows
message.c 1.42 -> 1.43
diff -u -r1.42 -r1.43
--- message.c	15 Aug 2004 21:36:30 -0000	1.42
+++ message.c	31 Aug 2004 23:32:01 -0000	1.43
@@ -1,4 +1,4 @@
-/* $Id: message.c,v 1.42 2004/08/15 21:36:30 chorns Exp $
+/* $Id: message.c,v 1.43 2004/08/31 23:32:01 gvg Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -541,15 +541,6 @@
           }
         break;
       }
-
-    case WM_GETTEXTLENGTH:
-    case CB_GETLBTEXTLEN:
-    case LB_GETTEXTLEN:
-      {
-        /* FIXME: There may be one DBCS char for each Unicode char */
-        *Result *= 2;
-        break;
-      }
     }
 
   MsgiAnsiToUnicodeCleanup(UnicodeMsg, AnsiMsg);
@@ -606,6 +597,17 @@
           UnicodeMsg->lParam = (LPARAM)CsA;
           break;
         }
+      case WM_GETTEXT:
+        {
+          /* Ansi string might contain MBCS chars so we need 2 * the number of chars */
+          AnsiMsg->wParam = UnicodeMsg->wParam * 2;
+          AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), 0, AnsiMsg->wParam);
+          if (NULL == (PVOID) AnsiMsg->lParam)
+            {
+              return FALSE;
+            }
+          break;
+        }
       case WM_SETTEXT:
         {
           ANSI_STRING AnsiString;
@@ -632,6 +634,10 @@
   switch(UnicodeMsg->message)
     {
       case WM_GETTEXT:
+        {
+          RtlFreeHeap(GetProcessHeap(), 0, (PVOID) AnsiMsg->lParam);
+          break;
+        }
       case WM_SETTEXT:
         {
           ANSI_STRING AString;
@@ -679,15 +685,6 @@
           }
         break;
       }
-
-    case WM_GETTEXTLENGTH:
-    case CB_GETLBTEXTLEN:
-    case LB_GETTEXTLEN:
-      {
-        /* FIXME: There may be one DBCS char for each Unicode char */
-        *Result /= sizeof(WCHAR);
-        break;
-      }
     }
 
   MsgiUnicodeToAnsiCleanup(UnicodeMsg, AnsiMsg);
CVSspam 0.2.8