输入“\”或“.”的时候弹出选择对话框,让你选择?
2004-04-16 13:15
288 查看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
ListBox1: TListBox;
procedure Memo1KeyPress(Sender: TObject; var Key: Char);
procedure ListBox1DblClick(Sender: TObject);
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
const
cInfo = ['/', '.'];
var
cPos: TPoint;
i: integer;
cText: String;
begin
GetCaretPos(cPos);
if Key in cInfo then
begin
for i := 0 to ListBox1.Items.Count-1 do
begin
cText := ListBox1.Items[i];
if cText[1] = Key then
begin
ListBox1.ItemIndex := i;
Break;
end;
end;
ListBox1.Visible := True;
ListBox1.Left := TMemo(Sender).Left+cPos.x;
ListBox1.Top := TMemo(Sender).Top+cPos.y+15;
end else
begin
ListBox1.Visible := False;
end;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
Memo1.Text := Copy(Memo1.Text, 0, Length(Memo1.Text)-1);
Memo1.Text := Memo1.Text+ListBox1.Items[ListBox1.ItemIndex];
ListBox1.Visible := False;
Memo1.SetFocus;
Memo1.SelStart := Length(Memo1.Text);
end;
procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ListBox1.Visible := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Visible := False;
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
ListBox1: TListBox;
procedure Memo1KeyPress(Sender: TObject; var Key: Char);
procedure ListBox1DblClick(Sender: TObject);
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
const
cInfo = ['/', '.'];
var
cPos: TPoint;
i: integer;
cText: String;
begin
GetCaretPos(cPos);
if Key in cInfo then
begin
for i := 0 to ListBox1.Items.Count-1 do
begin
cText := ListBox1.Items[i];
if cText[1] = Key then
begin
ListBox1.ItemIndex := i;
Break;
end;
end;
ListBox1.Visible := True;
ListBox1.Left := TMemo(Sender).Left+cPos.x;
ListBox1.Top := TMemo(Sender).Top+cPos.y+15;
end else
begin
ListBox1.Visible := False;
end;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
Memo1.Text := Copy(Memo1.Text, 0, Length(Memo1.Text)-1);
Memo1.Text := Memo1.Text+ListBox1.Items[ListBox1.ItemIndex];
ListBox1.Visible := False;
Memo1.SetFocus;
Memo1.SelStart := Length(Memo1.Text);
end;
procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ListBox1.Visible := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Visible := False;
end;
end.
相关文章推荐
- 各种对话框的实现(文字对话框,选择对话框,弹出输入对话框,单选,多选对话框,自定义对话框)
- MDI程序,添加多文档模板,点击New菜单项的时候弹出New对话框要求让用户选择的问题
- C#弹出选择对话框程序
- 选择某种Map集合保存学号从1到15的学员的学号(键)和姓名(值),学号用字符串表示,输入的时候要以学号乱序的方式存入Map集合,然后按照学号从大到小的顺序将Map集合中的元素输出打印。需要自定义Ma
- 每日学习心得:CustomValidator验证控件验证用户输入的字符长度、Linq 多字段分组统计、ASP.NET后台弹出confirm对话框,然后点击确定,执行一段代码
- MFC 对话框 button弹出对话框选择图片并用opencv Mat 加载
- 选择时间对话框,在点击对话框外面的时候对话框不会自动关闭
- winfrom对话框选择文件时候的过滤设置
- <转>Android开发使输入框点击弹出日期选择对话框的方法
- MFC下面弹出一个选择文件夹对话框
- 怎样弹出一个输入对话框
- Java--swing弹出框,多输入(选择)条件
- 弹出对话框,选择一个文件夹,返回文件夹path
- 在网页输入汉字时弹出启动对话框,原来是IETool.dll等捣鬼
- CS4:用户在使用IE访问FTP server 时遇到 502代理错误,没有弹出输入用户凭据对话框
- 查找当前目录下文件是否存在,不存在则弹出选择文件对话框
- Vb2010 弹出对话框来选择文件夹路径
- 不用点击file类型的input弹出文件选择对话框
- 用接口CL_GUI_FRONTEND_SERVICES弹出选择文件对话框
- DOM应用案例--选择输入对话框