昨夜看到一篇文章
中午找到輸入拼音可以檢索漢字
今天實現:
實現是靠的迂回策略(讀取數據庫漢字
下面附上Code:
{//漢字拼音碼檢索 對應的拼音字母}
function GetCharInd(zzchar:string):char;
begin
case WORD(zzchar[
$B
$B
$B
$B
$B
$B
$B
$B
$BBF
$BFA
$C
$C
$C
$C
$C
$C
$C
$C
$CBFA
$CDDA
$CEF
$D
$D
else
result:=#
end;
end;
{漢字拼音碼的檢索}
function DisByStrInd(ListBoxStr:TListBox;StrInd:string):string;
label NotFound;
var
zzchar :string;
i
begin
for i:=
begin
for j:=
begin
zzchar:=ListBoxStr
if (StrInd[j]<>
then goto NotFound;
end;
if result=
else result:=result+#
NotFound:
end;
end;
以下是Delphi
{********************************************************************}
{ *
*
*
*
*
*
{********************************************************************}
unit SelectByPinYin;
interface
uses
Windows
Dialogs
Buttons;
type
TSelectPY = class(TEDairyForm)
Panel
Panel
Panel
Panel
ListBox
Edit
Label
Label
BitBtn
BitBtn
ListBox
Label
procedure FormCreate(Sender: TObject);
procedure Edit
procedure ListBox
procedure ListBox
private
{ Private declarations }
public
{ Public declarations }
end;
var
SelectPY: TSelectPY;
getName:String;
{函數在這裡定義}
function GetCharInd(zzchar:string):char;//漢字拼音碼
function DisByStrInd(ListBoxStr:TListBox;StrInd:string):string;
implementation
uses DataMain;
{$R *
{//漢字拼音碼檢索 對應的拼音字母}
function GetCharInd(zzchar:string):char;
begin
case WORD(zzchar[
$B
$B
$B
$B
$B
$B
$B
$B
$BBF
$BFA
$C
$C
$C
$C
$C
$C
$C
$C
$CBFA
$CDDA
$CEF
$D
$D
else
result:=#
end;
end;
{漢字拼音碼的檢索}
function DisByStrInd(ListBoxStr:TListBox;StrInd:string):string;
label NotFound;
var
zzchar :string;
i
begin
for i:=
begin
for j:=
begin
zzchar:=ListBoxStr
if (StrInd[j]<>
then goto NotFound;
end;
if result=
else result:=result+#
NotFound:
end;
end;
{在 FormCreate 中
procedure TSelectPY
var
i:integer;
begin
inherited;
with adodm
begin
listBox
//用循環的方法加入
for i:=
begin
self
adodm
end;
listBox
adodm
end;
// edit
end;
//實現單擊選擇性名
procedure TSelectPY
var xIndex:integer;
begin
inherited;
xIndex:=self
label
getName:=self
end;
{輸入拼音查找漢字}
procedure TSelectPY
var
SelStr:string;
begin
inherited;
SelStr:=
ListBox
end;
{單擊選擇}
procedure TSelectPY
var nIndex:integer;
begin
inherited;
nIndex:=ListBox
ListBox
getName:=self
end;
end
From:http://tw.wingwit.com/Article/program/Delphi/201311/24657.html