高手高手,我要高手!!谁能解决这个问题?看看也会有收获的。 反查编码 如:“五笔”的五笔编码是ggtt 这可不是老调重谈!!

G

genue

Unregistered / Unconfirmed
GUEST, unregistred user!
高手高手,我要高手!!谁能解决这个问题?看看也会有收获的。 反查编码 如:“五笔”的五笔编码是ggtt 这可不是老调重谈!!(已解决,源码已上传见贴后) (100分)<br />我的程序源码在下,主要有以下现象:

在Win2000 Advance Server中,只能查五笔和微软拼音。当程序窗口激活时,用Ctrl和Shift把的有输入法切换一遍,就能查所有的了,不知为何?XP下即使如此,也查不出ABC的编码来。不知是否是要用一个什么“激活”所有输入法的API?

 
源码如下,加一个ListBox,2个edit,和一个Button即可

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Imm;

type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
edtExam: TEdit;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function QueryCompStr(hKB: HKL; const sChinese: AnsiString): string;
var
szBuffer: array[0..254] of char;
iStart: integer;
begin
Result := '';
if ImmEscape(hKB, 0, IME_ESC_MAX_KEY, nil) &lt;= 0 then exit;
if (ImmGetConversionList(hKB, 0, pchar(sChinese), @szBuffer, 255, GCL_REVERSECONVERSION)) &gt; 0 then
begin
iStart := byte(szBuffer[24]);
while szBuffer[iStart] &lt;&gt; #0 do
begin
Result := Result + szBuffer[iStart];
Inc(iStart);
end;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
iHandleCount: integer;
pList: array[1..20] of HKL;
szImeName: array[0..254] of char;
i: integer;
sFound: string;
begin
ListBox1.Items.Clear;
//取得目前系统已安装输入法之各个键盘配置(Keyboard Layout)
iHandleCount := GetKeyboardLayoutList(20, pList);
Edit1.Text := '';
for i := 1 to iHandleCount do
begin
if ImmEscape(pList, 0, IME_ESC_IME_NAME, @szImeName) &gt; 0 then
begin
Edit1.Text := Edit1.Text + '__' + Inttostr(pList);
sFound := QueryCompStr(pList, edtExam.Text);
ListBox1.Items.Add(StrPas(szImeName) + ': ' + sFound);
end;
end;
end;

end.

 
所有问题均已自解决,源码包在我的主页上去取:

http://www.135791.com
 
[:)]genue很可爱呀
 
顶部