[USER32|WIN32K]
authorRafal Harabien <rafalh@reactos.org>
Thu, 13 Oct 2011 14:01:01 +0000 (14:01 +0000)
committerRafal Harabien <rafalh@reactos.org>
Thu, 13 Oct 2011 14:01:01 +0000 (14:01 +0000)
- Convert wParam in WM_*CHAR messages to ANSI in GetMessageA instead of win32k. Fixes wrong characters used in cmake notepad which is ANSI.

svn path=/trunk/; revision=54109

reactos/dll/win32/user32/windows/message.c
reactos/subsystems/win32/win32k/ntuser/keyboard.c

index b3209b5..ea73945 100644 (file)
@@ -1703,6 +1703,28 @@ DispatchMessageW(CONST MSG *lpmsg)
 }
 
 
+static VOID
+IntConvertMsgToAnsi(LPMSG lpMsg)
+{
+    CHAR ch[2];
+    WCHAR wch[2];
+
+    switch (lpMsg->message)
+    {
+        case WM_CHAR:
+        case WM_DEADCHAR:
+        case WM_SYSCHAR:
+        case WM_SYSDEADCHAR:
+        case WM_MENUCHAR:
+            wch[0] = LOWORD(lpMsg->wParam);
+            wch[1] = HIWORD(lpMsg->wParam);
+            ch[0] = ch[1] = 0;
+            WideCharToMultiByte(CP_THREAD_ACP, 0, wch, 2, ch, 2, NULL, NULL);
+            lpMsg->wParam = MAKEWPARAM(ch[0] | (ch[1] << 8), 0);
+            break;
+    }
+}
+
 /*
  * @implemented
  */
@@ -1726,6 +1748,8 @@ GetMessageA(LPMSG lpMsg,
       return Res;
     }
 
+  IntConvertMsgToAnsi(lpMsg);
+
   return Res;
 }
 
index ee9118f..aec40d0 100644 (file)
@@ -1030,15 +1030,7 @@ IntTranslateKbdMessage(LPMSG lpMsg,
         for (i = 0; i < cch; ++i)
         {
             TRACE("Msg: %x '%lc' (%04x) %08x\n", NewMsg.message, wch[i], wch[i], NewMsg.lParam);
-            if (pWnd->Unicode)
-                NewMsg.wParam = wch[i];
-            else
-            {
-                CHAR ch;
-                if (!NT_SUCCESS(RtlUnicodeToMultiByteN(&ch, sizeof(ch), NULL, &wch[i], sizeof(wch[i]))))
-                    WARN("RtlUnicodeToMultiByteN failed!\n");
-                NewMsg.wParam = ch;
-            }
+            NewMsg.wParam = wch[i];
             MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY);
         }
         bResult = TRUE;