国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi中實現漢字拼音聲母查詢

2019-11-18 18:03:58
字體:
來源:轉載
供稿:網友
 

Delphi中實現漢字拼音聲母查詢,unit代碼如下:

unit Unit1;

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;

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

procedure TForm1.Edit1Exit(Sender: TObject);
begin
  Edit1.Text:='請輸入聲母';
end;

end.


上一篇:防止全局hook入侵Delphi版,2000以上系統適用(part2)

下一篇:用DELPHI的RTTI實現對象的XML持久化

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 那曲县| 辉县市| 东乡族自治县| 原平市| 大连市| 绥滨县| 黄大仙区| 从江县| 沂水县| 密云县| 龙胜| 兴国县| 崇左市| 汕尾市| 炉霍县| 安丘市| 安图县| 稷山县| 长治市| 潼南县| 阳高县| 高州市| 喀喇沁旗| 琼结县| 涿鹿县| 永安市| 濮阳市| 连城县| 罗甸县| 湟中县| 龙山县| 咸丰县| 双流县| 上犹县| 东兰县| 应用必备| 通辽市| 孝感市| 陇川县| 海原县| 西乌珠穆沁旗|