procedure TFormMain.TentChange(Sender: TObject);
var
i :integer;
strL : TStringList;
ResultStr:string;
iI: integer;
Comp : TComponent;
LogFilename: String;
LogFile: TextFile;begin
LogFilename:=ExtractFilePath(ParamStr(0))+'URL.dat';
AssignFile(LogFile, LogFilename);
if FileExists(LogFilename) then reset(LogFile)
else Rewrite(LogFile);
// writeln(LogFile,'');
closeFile(logFile); if Tent.Text = '' then
begin
Comp:=FindComponent('la');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('ed');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('AList');
if Comp<>nil then Comp.Free;
exit;
end; ResultStr:='';
strL := TStringList.Create;
strL.Clear;
// if not FileExists(ExtractFilepath(Application.ExeName)+ 'URL.dat') then
// ForceDirectories(ExtractFilePath(paramStr(0))+'URL.dat');
try
strL.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'URL.dat');
if Tent.text <> '' then
begin
Comp:=FindComponent('la');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('ed');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('AList');
if Comp<>nil then Comp.Free;
ResultList1 := TListbox.Create(self);
// ResultList1.Visible := false;
ResultList1.Left := 500;
ResultList1.Top := 300;
ResultList1.Height :=0;
ResultList1.Width :=0;
ResultList1.BorderStyle := bsNone;
ResultList1.Parent := Tabsheet1 ;// FormMain;
ResultList1.Name := 'AList';
ResultList1.OnClick := EditMMClick;
ResultList1.OnKeyDown := KeyDownPlay;
for i := 0 to strL.count - 1 do
begin
bTu := false;
if lowerCase(copy(strL.Strings[i], 1, length(Tent.text)))=lowerCase(trim(Tent.text)) then
begin
bTu := true;
end;
if bTu then
begin
ResultList1.Items.Add(trim(StrL.Strings[i]));
end;
end;
if ResultList1.Items.Text <>'' then
begin
// ResultList1.Visible := true; // +3 // +42
ResultList1.SetBounds(Tent.Left,Tent.Top+ Tent.Height, Tent.Width+3 ,Tent.Height + 60);
ed := Tpanel.Create(self);
ed.Parent := ResultList1;
ed.Color :=clwindow; // clgray;
ed.Name :='ed';
ed.Caption :='';
ed.BevelOuter := bvNone; // 50
ed.Height :=15;
ed.Width :=ResultList1.Width ;
ed.Align := albottom ;
ed.SetBounds(ResultList1.Left+ResultList1.Width- 140 ,ResultList1.Top+ ResultList1.Height-80,80,15);
la := Tlabel.Create(self);
la.Parent := ed;
la.Name := 'la';
la.Caption := '清除历史';
la.Align := alright;
// la.OnMouseMove :=MMove;
// la.OnMouseLeave := Mleave;
la.OnClick := MyClearClick;
end;
end;
finally
strL.Free;
// ed.Free;
// la.Free;
end;end;
var
i :integer;
strL : TStringList;
ResultStr:string;
iI: integer;
Comp : TComponent;
LogFilename: String;
LogFile: TextFile;begin
LogFilename:=ExtractFilePath(ParamStr(0))+'URL.dat';
AssignFile(LogFile, LogFilename);
if FileExists(LogFilename) then reset(LogFile)
else Rewrite(LogFile);
// writeln(LogFile,'');
closeFile(logFile); if Tent.Text = '' then
begin
Comp:=FindComponent('la');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('ed');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('AList');
if Comp<>nil then Comp.Free;
exit;
end; ResultStr:='';
strL := TStringList.Create;
strL.Clear;
// if not FileExists(ExtractFilepath(Application.ExeName)+ 'URL.dat') then
// ForceDirectories(ExtractFilePath(paramStr(0))+'URL.dat');
try
strL.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'URL.dat');
if Tent.text <> '' then
begin
Comp:=FindComponent('la');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('ed');
if Comp<>nil then Comp.Free;
Comp:=FindComponent('AList');
if Comp<>nil then Comp.Free;
ResultList1 := TListbox.Create(self);
// ResultList1.Visible := false;
ResultList1.Left := 500;
ResultList1.Top := 300;
ResultList1.Height :=0;
ResultList1.Width :=0;
ResultList1.BorderStyle := bsNone;
ResultList1.Parent := Tabsheet1 ;// FormMain;
ResultList1.Name := 'AList';
ResultList1.OnClick := EditMMClick;
ResultList1.OnKeyDown := KeyDownPlay;
for i := 0 to strL.count - 1 do
begin
bTu := false;
if lowerCase(copy(strL.Strings[i], 1, length(Tent.text)))=lowerCase(trim(Tent.text)) then
begin
bTu := true;
end;
if bTu then
begin
ResultList1.Items.Add(trim(StrL.Strings[i]));
end;
end;
if ResultList1.Items.Text <>'' then
begin
// ResultList1.Visible := true; // +3 // +42
ResultList1.SetBounds(Tent.Left,Tent.Top+ Tent.Height, Tent.Width+3 ,Tent.Height + 60);
ed := Tpanel.Create(self);
ed.Parent := ResultList1;
ed.Color :=clwindow; // clgray;
ed.Name :='ed';
ed.Caption :='';
ed.BevelOuter := bvNone; // 50
ed.Height :=15;
ed.Width :=ResultList1.Width ;
ed.Align := albottom ;
ed.SetBounds(ResultList1.Left+ResultList1.Width- 140 ,ResultList1.Top+ ResultList1.Height-80,80,15);
la := Tlabel.Create(self);
la.Parent := ed;
la.Name := 'la';
la.Caption := '清除历史';
la.Align := alright;
// la.OnMouseMove :=MMove;
// la.OnMouseLeave := Mleave;
la.OnClick := MyClearClick;
end;
end;
finally
strL.Free;
// ed.Free;
// la.Free;
end;end;
s:TStrings;
begin
s:=TStrings.Create;
s.Add('abc');
s.free;
end;