⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 无解压密码
💻 PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox2: TListBox;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    ListBox1: TListBox;
    procedure Edit1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

function GetCharInd(zzchar:string):char;  //得到汉字的第一个拼音字母
begin
  case WORD(zzchar[1]) shl 8+WORD(zzchar[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:=#0;
  end;
end;

function DisByStrInd(ListBoxStr:TListBox;StrInd:string):string;
label NotFound;
var
  zzchar :string;
  i,j:integer;
begin
  for i:=0 to ListBoxStr.Items.Count-1 do //检查每一行汉字
  begin
      for j:=1 to Length(StrInd) do  //检查每个汉字对应的拼音
      begin
        zzchar:=ListBoxStr.Items[i][2*j-1]+ListBoxStr.Items[i][2*j];
        if (StrInd[j]<>'?') and (UpperCase(StrInd[j])<>GetCharInd(zzchar))
        then goto NotFound;
      end;
      if result='' then result:=ListBoxStr.Items[i]
      else result:=result+#13+ListBoxStr.Items[i];
      NotFound: //该行汉字不符合拼音输入
  end;
end;

{$R *.DFM}

procedure TForm1.Edit1Change(Sender: TObject);
var
  SelStr:string;
begin
  SelStr:='';
  ListBox2.Items.Text:=DisByStrInd(ListBox1,Edit1.Text);//选择listbox1中以edit1拼音开头的词语
end;

procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
with OpenDialog1 do
 begin
 if Execute then
 begin
 memo1.Lines.LoadFromFile(FileName);
 listbox1.Items:=memo1.Lines;
 end;
 end;
 edit1.SetFocus;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -