1.FormCreate(Sender: TObject);
var
i: integer;
begin
II := 0;
//retrieves the keyboard layout handles corresponding to the current set of input locales in the system.
iHandleCount := GetKeyboardLayoutList(20, pList);
for i := 1 to iHandleCount do
begin
if ImmEscape(pList[i], 0, IME_ESC_IME_NAME, @szImeName) > 0 then
if szImeName=''微软拼音输入法'' then
begin
StdCtrls, ExtCtrls, Buttons, IMM;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Edit2: TEdit;
Edit1: TEdit;
Label5: TLabel;
Label1: TLabel;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
public
iHandleCount: integer;
pList : array[1..20] of HKL;
szImeName : array[0..254] of char;
II : integer;
end;
const
pych: array[1..6,1..5] of string=
((''ā'', ''á'',''ǎ'',''à'',''a''),(''ō'', ''ó'',''ǒ'',''ò'',''o''),
(''ē'', ''é'',''ě'',''è'',''e''),(''ī'', ''í'',''ǐ'',''ì'',''i''),
(''ū'', ''ú'',''ǔ'',''ù'',''u''),(''ǖ'', ''ǘ'',''ǚ'',''ǜ'',''ü''));
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
II := 0;
//retrieves the keyboard layout handles corresponding to the current set of input locales in the system.
iHandleCount := GetKeyboardLayoutList(20, pList);
for i := 1 to iHandleCount do
begin
if ImmEscape(pList[i], 0, IME_ESC_IME_NAME, @szImeName) > 0 then
if szImeName=''微软拼音输入法'' then
begin
ii := i;
exit;
end;
end;
ShowMessage(''请你安装"微软拼音输入法"!'');
end;
// 选择需要标注拼音的文件:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
OpenDialog1.Title := ''选择需要转换的文件'';
if OpenDialog1.Execute then
Edit1.Text := OpenDialog1.FileName;
Edit2.Text := ChangeFileExt(OpenDialog1.FileName, ''.py'');
end;
// 拼音文件保存到
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
OpenDialog1.Title := ''转换到:'';
if OpenDialog1.Execute then
Edit2.Text := OpenDialog1.FileName;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
f1 ,f2 :textfile;
ch1,ch2,ch11 :Char;
ch2Str :string;
j ,alr , tmp :integer;
py : array[1..6] of integer;
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;
// 看看这个输入法是否支持Reverse Conversion功能,同时, 侦测需要多大的空间容纳取得的信息
dwGCL := ImmGetConversionList(hKB, 0, pchar(sChinese),nil, 0, GCL_REVERSECONVERSION);
if dwGCL <= 0 then Exit; // 该输入法不支持Reverse Conversion功能
// 取得组字字根信息, dwGCL的值必须用上次呼叫ImmGetConversionList得到的返回值作为参数
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, szB