Delphi中实现汉字拼音声母查询

李丽丽780

李丽丽780

2016-02-19 18:49

下面是个超简单的Delphi中实现汉字拼音声母查询教程,图老师小编精心挑选推荐,大家行行好,多给几个赞吧,小编吐血跪求~
 

  Delphi中实现汉字拼音声母查询,unit代码如下:
  
  unit Unit1;

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  interface

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

  type
    TForm1 = class(TForm)
      ListBox1: TListBox;
      ListBox2: TListBox;
      Edit1: TEdit;
      Label1: TLabel;
      procedure Edit1Change(Sender: TObject);
      procedure FormShow(Sender: TObject);
      procedure FormDestroy(Sender: TObject);
      procedure Edit1Enter(Sender: TObject);
      procedure Edit1Exit(Sender: TObject);
    private
      { Private declarations }
    public
       ResultList1:TStrings;
    end;

  var
    Form1: TForm1;

    procedure SearchByPyIndexStr(PYIndexStr :string);

  implementation

  {$R *.DFM}
  function GetPyIndexChar(Hzchar:string):String;
  begin
     case (Word(hzchar[1]) shl 8 + Word(hzchar[2])) of
        $B0A1..$B0C4 : Result :='A';
        $B0C5..$B2C0 : Result :='B';
        $B2C1..$B4ED : Result :='C';
        $B4EE..$B6E9 : Result :='D';
        $B6EA..$B7A1 : Result :='E';
        $B7A2..$B8C0 : Result :='F';
        $B8C1..$B9FD : Result :='G';
        $B9FE..$BBF6 : Result :='H';
        $BBF7..$BFA5 : Result :='J';
        $BFA6..$C0AB : Result :='K';
        $C0AC..$C2E7 : Result :='L';
        $C2E8..$C4C2 : Result :='M';
        $C4C3..$C5B5 : Result :='N';
        $C5B6..$C5BD : Result :='O';
        $C5BE..$C6D9 : Result :='P';
        $C6DA..$C8BA : Result :='Q';
        $C8BB..$C8F5 : Result :='R';
        $C8F6..$CBF9 : Result :='S';
        $CBFA..$CDD9 : Result :='T';
        $CDDA..$CEF3 : Result :='W';
        $CEF4..$D1B8 : Result :='X';
        $D1B9..$D4D0 : Result :='Y';
        $D4D1..$D7F9 : Result :='Z';
     else
        Result := char(0);
     end;
  end;

  procedure SearchByPyIndexStr(PYIndexStr :string);
  label NotFound;
  var
     I, J :Integer;
     Hzchar :String;
  begin
     For I:=0 to Form1.ListBox1.Items.Count-1 do
     begin
        For J:=1 to Length(PYIndexStr) do
        begin
           Hzchar :=Form1.ListBox1.Items[I][2*J-1]+Form1.ListBox1.Items[I][2*J];
           if (PYIndexStr[J] '?') and (UpperCase(PYIndexStr[J])GetPyIndexChar(Hzchar)) then
              goto NotFound;
        end;
        Form1.ResultList1.Add(Form1.ListBox1.Items[I]);
        NotFound:
     end;
  end;

  procedure TForm1.Edit1Change(Sender: TObject);
  begin
    if Edit1.Text'' then
    begin
      ListBox2.Items.Clear;
      Form1.ResultList1.Clear;
      SearchByPyIndexStr(edit1.text);
      ListBox2.Items.AddStrings(ResultList1);
    end;
  end;

  procedure TForm1.FormShow(Sender: TObject);
  begin
    ResultList1:=TStringList.Create;
  end;

  procedure TForm1.FormDestroy(Sender: TObject);
  begin
    ResultList1.Free;
  end;

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  procedure TForm1.Edit1Enter(Sender: TObject);
  begin
    Edit1.Text:='';
  end;

  procedure TForm1.Edit1Exit(Sender: TObject);
  begin
    Edit1.Text:='请输入声母';
  end;

  end.

展开更多 50%)
分享

猜你喜欢

Delphi中实现汉字拼音声母查询

编程语言 网络编程
Delphi中实现汉字拼音声母查询

Delphi中实现多线程同步查询(2)

Delphi
Delphi中实现多线程同步查询(2)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Delphi中实现多线程同步查询(1)

Delphi
Delphi中实现多线程同步查询(1)

WPS文字拼音标注技巧实现看拼音写汉字或给汉字注音

电脑应用 计算机应用技术
WPS文字拼音标注技巧实现看拼音写汉字或给汉字注音

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

输入汉字自动转为拼音(jsp实现方式)

Web开发
输入汉字自动转为拼音(jsp实现方式)

用ASP实现汉字转拼音的功能

ASP
用ASP实现汉字转拼音的功能

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Winsock完成端口模型-Delphi代码

Winsock完成端口模型-Delphi代码

明白会有心疼的一天

明白会有心疼的一天
下拉加载更多内容 ↓