链接:https://pan.baidu.com/s/1cST-NSoy2ZFh-FQ44L3XxA
提取码:rgca
2]汉字拼音带出
要手动编辑EXE目录 下的History.txt文件
通过网盘分享的文件:CoboboxLike5.rar
链接: https://pan.baidu.com/s/1YvC2vpdnxH7SPcgyyBfdgA 提取码: 6c6r
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | procedure TForm1 . Edit1Change(Sender: TObject); //输入 时 实时 筛选 var i: integer ; begin ListBox2 . Visible:= false ; ListBox2 . Items . Clear; for i := 0 to aStringList . Count - 1 do begin if pos( Edit1 . Text, aStringList[i])> 0 then begin ListBox2 . Items . Add(aStringList[i]) end ; end ; ListBox2 . Visible:=ListBox2 . Items . Count> 0 ; end ; procedure TForm1 . Edit1KeyDown(Sender: TObject; var Key: Word ; Shift: TShiftState); begin if ( key=VK_DOWN) and (listbox2 . Items . Count> 0 ) then begin //按 向下键,选择 ListBox2 . SetFocus; ListBox2 . ItemIndex:= 0 ; end ; end ; procedure TForm1 . Edit1KeyPress(Sender: TObject; var Key: Char ); begin if key=# 13 then begin // 按回车键,Edit内容 添加到 历史记录里 aStringList . Add(Edit1 . Text) end end ; procedure TForm1 . FormClose(Sender: TObject; var Action: TCloseAction); begin aStringList . SaveToFile( 'History.txt' ); //退出时,将历史记录保存到 硬盘里 aStringList . Free; end ; procedure TForm1 . FormCreate(Sender: TObject); begin aStringList:= tStringList . Create; aStringList . sorted := True ; //历史记录 去除功能 aStringList . Duplicates := dupIgnore; // aStringList.Add('aa'); // aStringList.Add('ab'); // aStringList.Add('cc'); // aStringList.Add('bc'); // aStringList.Add('dd'); aStringList . LoadFromFile( 'History.txt' ); //启动时,加载历史记录 end ; procedure TForm1 . ListBox2KeyPress(Sender: TObject; var Key: Char ); begin if (key=# 13 ) and (listbox2 . Items . Count> 0 ) then begin //选择 历史记录 项 Edit1 . Text:= listbox2 . Items[listbox2 . ItemIndex]; edit1 . SetFocus; listbox2 . Visible:= false ; end end ; end . |
就像Chrome网址输入栏一样记录历史网址一样
1[输入时,若历史记录中有,则实时带出,模糊记录(部分包含),按 向下键,可以选择历史 项,
2]若历史记录没有,按回车,则加入到历史记录中,下次 输入则会带出来
添加功能,模糊带出时,突出模糊字符串
0]要将ListBox的Style设为lbOwnerDrawFixed
调整ListBox2的字体大小后,记得调整它的ItemHeight
增加大小写不敏感查询
procedure TForm1.ListBox2DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var aX:integer; leftStr,midStr,rightStr,yyyStr:string; begin ax := Rect.Left ; midStr:=lowercase(edit1.Text); ListBox2.Canvas.Font.Color := clblack; leftStr:=copy( ListBox2.Items[index] ,1 ,pos(midStr, lowercase(ListBox2.Items[index]))-1); // 左 文字 ListBox2.Canvas.TextOut(ax , Rect.Top ,leftStr); Inc(ax, ListBox2.Canvas.TextWidth(leftStr)); ax:=ax+1; //===================================================================================== ListBox2.Canvas.Font.Color := clred; // 中 文字 yyyStr:=copy( ListBox2.Items[index] , pos(midStr, lowercase(ListBox2.Items[index])) , length(midStr) ); ListBox2.Canvas.TextOut(ax , Rect.Top ,yyyStr); Inc(ax, ListBox2.Canvas.TextWidth(yyyStr)); ax:=ax+1; //===================================================================================== ListBox2.Canvas.Font.Color := clblack; rightStr:=copy( ListBox2.Items[index] ,pos(midStr, lowercase(ListBox2.Items[index]))+length(midStr) ,100 ); // 右 文字 ListBox2.Canvas.TextOut(ax , Rect.Top ,rightStr); end;
链接:https://pan.baidu.com/s/1cST-NSoy2ZFh-FQ44L3XxA
提取码:rgca
分类:
Delphi7相关
, Delphi2010
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律