diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-10-12 14:39:48 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-10-12 14:39:48 +0000 |
commit | 5ffc266079c2ee60bd607472790226bcbdd51ea0 (patch) | |
tree | 3e651f2a6c1f8acebe0b9636a5156f80b6b6adb8 /packages/ptc/src/win32/base | |
parent | 0819c607862b9ae19712ebe99daee96fe8c7bdb9 (diff) | |
download | fpc-5ffc266079c2ee60bd607472790226bcbdd51ea0.tar.gz |
* Win32 kbd input unicode translation via MultiByteToWideChar
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@16144 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/ptc/src/win32/base')
-rw-r--r-- | packages/ptc/src/win32/base/kbd.inc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/packages/ptc/src/win32/base/kbd.inc b/packages/ptc/src/win32/base/kbd.inc index 56bfcba8ff..5a6b56ed65 100644 --- a/packages/ptc/src/win32/base/kbd.inc +++ b/packages/ptc/src/win32/base/kbd.inc @@ -78,7 +78,8 @@ var AsciiBuf: Word; press: Boolean; uni: Integer; - tmp: Integer; + TranslatedCharacters, TranslatedWideCharacters: Integer; + WideStr: WideString; KeyCode: Integer; begin Result := 0; @@ -117,21 +118,18 @@ begin begin scancode := (lParam shr 16) and $FF; {todo: ToUnicode (Windows NT)} - tmp := ToAscii(wParam, scancode, @KeyStateArray, @AsciiBuf, 0); - if (tmp = 1) or (tmp = 2) then + TranslatedCharacters := ToAscii(wParam, scancode, @KeyStateArray, @AsciiBuf, 0); + if (TranslatedCharacters = 1) or (TranslatedCharacters = 2) then begin - if tmp = 2 then + TranslatedWideCharacters := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, @AsciiBuf, TranslatedCharacters, nil, 0); + if TranslatedWideCharacters <> 0 then begin -// Writeln('[', AsciiBuf, ']'); {???? todo: dead keys ????} - end - else - begin -// Write(Chr(AsciiBuf)); - {todo: codepage -> unicode} - if (AsciiBuf and $FF) <= 126 then - uni := AsciiBuf and $FF; - end; + SetLength(WideStr, TranslatedWideCharacters); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, @AsciiBuf, TranslatedCharacters, @WideStr[1], TranslatedWideCharacters); + if Length(WideStr) = 1 then + uni := Ord(WideStr[1]); + end; end; end; |