根据汉字查输入法的编码

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
function QueryCompStr(hKB: HKL; const sChinese: AnsiString): string; var
dwGCL: DWORD;
szBuffer: array[0..254] of char;
iMaxKey, iStart, i: integer;
begin
Result := '';
iMaxKey := ImmEscape(hKB, 0, IME_ESC_MAX_KEY, nil);
if iMaxKey <= 0 then exit;
dwGCL := ImmGetConversionList(hKB,0,pchar(sChinese),nil,0,GCL_REVERSECONVERSION);
if dwGCL <= 0 then Exit;
dwGCL := ImmGetConversionList(hKB,0,pchar(sChinese),@szBuffer,dwGCL,GCL_REVERSECONVERSION);
if dwGCL > 0 then
begin
iStart := byte(szBuffer[24]);
for i := iStart to iStart + iMaxKey * 2 do
AppendStr(Result, szBuffer);
end;
end;
但是上面的程序有问题,解决如下:
------------------------------------------------------------
在QueryCompStr中做如下修改就好(test in:win98 se+delphi5)
dwGCL := dwGCL+sizeof(TCandidateList); //add this line then ok,编码查询功能只支持单字,不支持词组。
dwGCL := ImmGetConversionList(hKB,0,pchar(sChinese),@szBuffer,dwGCL,GCL_REVERSECONVERSION);
----------------------------------------------------------------
按照pqx给我的答案,问题已解决部分,但用这种方法并不是所有的输入法都能查出,而用Windows自已的编码查询功能(右击输入法提示条,设置->编码查询,选择相应的输入法)则都能查出来,这是为什么呢?(如“王码五笔4.0”就查不出,而微软的“王码五笔86版”、“王码五笔98版”则都能查到。)
反查编码的的例子可以到 http://www.mildragon.com 的“学习园地”下载。本例是改自台湾钱达智先生的一个例子QRYCOMP(可以在Delphi深度历险中下载)。
*********
var
iHandleCount: integer;
pList: array[1..nHKL_LIST] of HKL;
szImeName: array[0..254] of char;
i: integer;
sFound: string;
begin
lstComposition.Items.Clear;
iHandleCount := GetKeyboardLayoutList(nHKL_LIST, pList);
for i := 1 to iHandleCount do
begin
if ImmEscape(pList, 0, IME_ESC_IME_NAME, @szImeName) > 0 then
begin
sFound := QueryCompStr(pList, edtExam.Text);
if sFound <> '' then
lstComposition.Items.Add(StrPas(szImeName) + ': ' + sFound);
end;
end;
 

Similar threads

I
回复
0
查看
535
import
I
I
回复
0
查看
601
import
I
I
回复
0
查看
633
import
I
I
回复
0
查看
566
import
I
顶部