Como posso fazer procura e ocultar caminho
11/02/2003
0
Pessoal gostaria de poder fazer uma procura nesta unit... um filtro para listar somente o que o usuario digitar e ao mesmo tempo ocultar o caminho... ao invés de ficar 22:05:10 D:\musicas\internacionais\Alan Jackson - All Try.... ficasse assim... 22:05:10 Alan Jackson - All try....alguém pode me ajudar... abaixo segue como a unit está... se alguém puder ajudar ficarei muito agradecido....
unit UnitViewLogs;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ComCtrls, ExtCtrls, Menus;
type
TfrmViewLogs = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
RichEdit1: TRichEdit;
Panel10: TPanel;
Panel3: TPanel;
FileListBox1: TFileListBox;
PopupMenu1: TPopupMenu;
Localizaritem1: TMenuItem;
ContinuarPesquisa1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FileListBox1DblClick(Sender: TObject);
procedure Localizaritem1Click(Sender: TObject);
procedure PopupMenu1Popup(Sender: TObject);
procedure ContinuarPesquisa1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
v_Busca: String;
end;
var
frmViewLogs: TfrmViewLogs;
implementation
{$R *.dfm}
procedure TfrmViewLogs.FormCreate(Sender: TObject);
begin
v_Busca := ´´;
if not ForceDirectories(ExtractFileDir(Application.ExeName) + ´\Logs´) then
begin
ShowMessage(´Não foi possível abrir diretório de Logs!´);
Close;
end
else
begin
FileListBox1.Directory := ExtractFileDir(Application.ExeName) + ´\Logs´;
end;
end;
procedure TfrmViewLogs.FileListBox1DblClick(Sender: TObject);
begin
if FileListBox1.FileName <> ´´ then
RichEdit1.Lines.LoadFromFile(FileListBox1.FileName);
end;
procedure TfrmViewLogs.Localizaritem1Click(Sender: TObject);
var
v_FoundAt: LongInt;
begin
with RichEdit1 do
begin
v_Busca := InputBox(´Localizar´,´Texto´,v_Busca);
if v_Busca <> ´´ then
begin
v_FoundAt := FindText(v_Busca, 0, Length(Text), []);
if v_FoundAt <> -1 then
begin
SetFocus;
SelStart := v_FoundAt;
SelLength := Length(v_Busca);
end;
end;
end;
end;
procedure TfrmViewLogs.PopupMenu1Popup(Sender: TObject);
begin
ContinuarPesquisa1.Enabled := (v_Busca <> ´´);
end;
procedure TfrmViewLogs.ContinuarPesquisa1Click(Sender: TObject);
var
v_FoundAt: LongInt;
begin
with RichEdit1 do
begin
v_FoundAt := FindText(v_Busca, SelStart + Length(v_Busca),
Length(Text) - SelStart - Length(v_Busca),
[]);
if v_FoundAt <> -1 then
begin
SetFocus;
SelStart := v_FoundAt;
SelLength := Length(v_Busca);
end;
end;
end;
end.
unit UnitViewLogs;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ComCtrls, ExtCtrls, Menus;
type
TfrmViewLogs = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
RichEdit1: TRichEdit;
Panel10: TPanel;
Panel3: TPanel;
FileListBox1: TFileListBox;
PopupMenu1: TPopupMenu;
Localizaritem1: TMenuItem;
ContinuarPesquisa1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FileListBox1DblClick(Sender: TObject);
procedure Localizaritem1Click(Sender: TObject);
procedure PopupMenu1Popup(Sender: TObject);
procedure ContinuarPesquisa1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
v_Busca: String;
end;
var
frmViewLogs: TfrmViewLogs;
implementation
{$R *.dfm}
procedure TfrmViewLogs.FormCreate(Sender: TObject);
begin
v_Busca := ´´;
if not ForceDirectories(ExtractFileDir(Application.ExeName) + ´\Logs´) then
begin
ShowMessage(´Não foi possível abrir diretório de Logs!´);
Close;
end
else
begin
FileListBox1.Directory := ExtractFileDir(Application.ExeName) + ´\Logs´;
end;
end;
procedure TfrmViewLogs.FileListBox1DblClick(Sender: TObject);
begin
if FileListBox1.FileName <> ´´ then
RichEdit1.Lines.LoadFromFile(FileListBox1.FileName);
end;
procedure TfrmViewLogs.Localizaritem1Click(Sender: TObject);
var
v_FoundAt: LongInt;
begin
with RichEdit1 do
begin
v_Busca := InputBox(´Localizar´,´Texto´,v_Busca);
if v_Busca <> ´´ then
begin
v_FoundAt := FindText(v_Busca, 0, Length(Text), []);
if v_FoundAt <> -1 then
begin
SetFocus;
SelStart := v_FoundAt;
SelLength := Length(v_Busca);
end;
end;
end;
end;
procedure TfrmViewLogs.PopupMenu1Popup(Sender: TObject);
begin
ContinuarPesquisa1.Enabled := (v_Busca <> ´´);
end;
procedure TfrmViewLogs.ContinuarPesquisa1Click(Sender: TObject);
var
v_FoundAt: LongInt;
begin
with RichEdit1 do
begin
v_FoundAt := FindText(v_Busca, SelStart + Length(v_Busca),
Length(Text) - SelStart - Length(v_Busca),
[]);
if v_FoundAt <> -1 then
begin
SetFocus;
SelStart := v_FoundAt;
SelLength := Length(v_Busca);
end;
end;
end;
end.
Markinhos
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)