problema com focus!!!

27/04/2003

0

tenho um problema de focus... num edit fiz uma pesquisa (filtro) com o focus tudo bonitinho...mas o problema é que quando vou digitar algo seguido de um espaço... o espaço não pega... somente pega se eu fizer com o control apertado... tipo assim Ctrl+spaço... alguém pode me ajudar???

abaixo segue o codigo e obrigado a quem puder me ajudar... :shock:

unit UnitReproducoes;

interface

{$WARN UNIT_PLATFORM OFF}

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, IniFiles,
StdCtrls, FileCtrl, Menus, ImgList, ComCtrls, ExtCtrls, Buttons;

{$WARN UNIT_PLATFORM ON}

type
TfrmReproducoes = class(TForm)
Panel1: TPanel;
Panel4: TPanel;
lv_Sessoes: TListView;
ImageList1: TImageList;
Panel2: TPanel;
Panel3: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
flb_Arquivos: TFileListBox;
Edit1: TEdit;
Label1: TLabel;
sb_Inserir: TSpeedButton;
sb_Fechar: TSpeedButton;
cb_RetornoAutomatico: TCheckBox;
Panel8: TPanel;
PopupMenu1: TPopupMenu;
Adicionarnovacategoria1: TMenuItem;
N1: TMenuItem;
Removercategoria1: TMenuItem;
Renomear1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure flb_ArquivosDblClick(Sender: TObject);
procedure sb_FecharClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure sb_InserirClick(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure lv_SessoesSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure FormDeactivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
v_PlayList : TListView;
v_Index : Integer;
v_Sessao : String;
v_Path : String;
v_Image : Integer;
f_Sessoes : TIniFile;
f_Config : TIniFile;
constructor Create(Sender: TComponent; v_PL: TListView; i: Integer);
end;

var
frmReproducoes : TfrmReproducoes;

implementation

uses UnitPrincipal;

{$R *.DFM}

constructor TfrmReproducoes.Create(Sender: TComponent; v_PL: TListView; i: Integer);
begin
v_PlayList := v_PL;
v_Index := i;
inherited Create(Sender);
end;

procedure TfrmReproducoes.FormCreate(Sender: TObject);
var
a_Sessoes: TStrings;
v_Item : TListItem;
i : Integer;
begin

try

v_Path := ExtractFileDir(Application.ExeName);

case v_Index of
2:
begin
v_Sessao := ´Propagandas´;
v_Image := 3;
end;
3:
begin
v_Sessao := ´Backgrounds´;
v_Image := 1;
end;
4:
begin
v_Sessao := ´Vinhetas´;
v_Image := 0;
end;
0:
begin
v_Sessao := ´Músicas´;
v_Image := 2;
end;
6:
begin
v_Sessao := ´Locuções´;
v_Image := 4;
end;
end;

Caption := Caption + v_Sessao;

//******* config *******//
f_Config := TIniFile.Create(v_Path + ´\´ + v_Sessao + ´\Config.cfg´);

cb_RetornoAutomatico.Checked := f_Config.ReadBool (´Configuracoes´,´RetornoAutomatico´,False);
Panel8.Caption := f_Config.ReadString(´Configuracoes´,´TituloJanela´,´´);
flb_Arquivos.Directory := f_Config.ReadString(´Configuracoes´,´Path´,´´);

//******* sessões ******//
f_Sessoes := TIniFile.Create(v_Path + ´\´ + v_Sessao + ´\Sessoes.dat´);

a_Sessoes := TStringList.Create;
f_Sessoes.ReadSections(a_Sessoes);

for i := 0 to a_Sessoes.Count -1 do
begin
v_Item := lv_Sessoes.Items.Add;
v_Item.ImageIndex := v_Image;
v_Item.Caption := a_Sessoes[i];
end;
//**********************//

a_Sessoes.Free;
except
On E: Exception do
begin
ShowMessage(´erro: ´+E.Message);
Close;
end;
end;
end;

procedure TfrmReproducoes.flb_ArquivosDblClick(Sender: TObject);
var
v_Item : TListItem;
v_Pasta : String;
v_Size : Integer;
begin
try
v_Pasta := Panel8.Caption;
with frmPrincipal do
begin

if (flb_Arquivos.Items.Count > 0) and (flb_Arquivos.FileName <> ´´) then
begin

v_Size := SizeSoundFile(flb_Arquivos.FileName,v_Index,v_Pasta);
//********** corpo de informações para o playlist ***********//
v_Item := v_PlayList.Items.Add;

if v_Size > -1 then
v_Item.ImageIndex := v_Index
else
v_Item.ImageIndex := 12;

v_Item.Caption := Titulo(flb_Arquivos.FileName);
v_Item.SubItems.Add(TimeToStr(MSecsToTime(v_Size)));
v_Item.SubItems.Add(flb_Arquivos.FileName);
v_Item.SubItems.Add(´ ´);

if v_Index <> 3 then
begin
v_Item.SubItems.Add(IntToStr(v_Size));

if v_PlayList.Name = ´ListView1´ then
v_TempoTotBloco1 := v_TempoTotBloco1 + MSecsToTime(v_Size)
else if v_PlayList.Name = ´ListView2´ then
v_TempoTotBloco2 := v_TempoTotBloco2 + MSecsToTime(v_Size);
end
else
v_Item.SubItems.Add(´0´);
//***********************************************************//
v_Item.SubItems.Add(Panel8.Caption); // *** Para o Controle
//***********************************************************//

if cb_RetornoAutomatico.Checked then
Self.Close;

end;
end;
except
v_Item.Delete;
end;
end;

procedure TfrmReproducoes.sb_FecharClick(Sender: TObject);
begin
Close;
end;

procedure TfrmReproducoes.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if v_Encerrar then
begin
// f_Sessoes.Free;
// f_Config.Free;

Action := caFree
end
else
begin
f_Config.WriteBool (´Configuracoes´,´RetornoAutomatico´,cb_RetornoAutomatico.Checked);
f_Config.WriteString(´Configuracoes´,´TituloJanela´,Panel8.Caption);
f_Config.WriteString(´Configuracoes´,´Path´,flb_Arquivos.Directory);
f_Config.UpdateFile;

Action := caNone;
Self.Visible := False;
v_PlayList.SetFocus;
end;
end;

procedure TfrmReproducoes.sb_InserirClick(Sender: TObject);
var
i, v_Size : Integer;
v_Pasta : String;
v_Item : TListItem;
z : Integer;
begin
try

v_Pasta := Panel8.Caption;

z := 0;

for i := 0 to flb_Arquivos.Items.Count -1 do
begin

if flb_Arquivos.Selected[i] then
begin

with frmPrincipal do
begin

v_Size := SizeSoundFile(flb_Arquivos.Directory+´\´+flb_Arquivos.Items.Strings[i], v_Index, v_Pasta);

//********** corpo de informações para o playlist ***********//

if v_PlayList.Selected <> nil then
v_Item := v_PlayList.Items.Insert(v_PlayList.Selected.Index+1+z)
else
v_Item := v_PlayList.Items.Add;

Inc(z);

if v_Size > -1 then
v_Item.ImageIndex := v_Index
else
v_Item.ImageIndex := 12;

v_Item.Caption := Titulo(flb_Arquivos.Items.Strings[i]);
v_Item.SubItems.Add(TimeToStr(MSecsToTime(v_Size)));
v_Item.SubItems.Add(flb_Arquivos.Directory + ´\´ + flb_Arquivos.Items.Strings[i]);
v_Item.SubItems.Add(´ ´);

if v_Index <> 3 then
begin
v_Item.SubItems.Add(IntToStr(v_Size));

if v_PlayList.Name = ´ListView1´ then
v_TempoTotBloco1 := v_TempoTotBloco1 + MSecsToTime(v_Size)
else if v_PlayList.Name = ´ListView2´ then
v_TempoTotBloco2 := v_TempoTotBloco2 + MSecsToTime(v_Size);
end
else
v_Item.SubItems.Add(´0´);
//***********************************************************//
v_Item.SubItems.Add(Panel8.Caption); // *** Para o Controle
//***********************************************************//

end;

end;

end;

if cb_RetornoAutomatico.Checked then
Close;

except
v_Item.Delete;
end;
end;

procedure TfrmReproducoes.Edit1Change(Sender: TObject);
begin
flb_Arquivos.Mask := ´*´+Edit1.Text+´*.mp3;*´+Edit1.Text+´*.wav´;
end;

procedure TfrmReproducoes.lv_SessoesSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
if Selected then
begin
flb_Arquivos.Directory := v_Path + ´\´ + v_Sessao + ´\´ + Item.Caption;
Panel8.Caption := Item.Caption;
end;
end;

procedure TfrmReproducoes.FormDeactivate(Sender: TObject);
begin
Edit1.Text := ´´;
end;

end.


Markinhos

Markinhos

Responder

Posts

27/04/2003

Obubiba

Não sei se entendi bem, seu problema, mas vamos lá:

No OnKeyDown do edit, verifique o valor da variável Key. Caso seja igual ao ASCII de Espaco(43 se não me engano), adicione o espaco ao edit:

if Key = 43 then
Edit.text := Edit.text + chr(43);


* Talvez o valor de Espaço não seja 43, dá uma olhadinha no valor de Key, quando você pressionar o Espaço.


Responder

28/04/2003

Markinhos

não funcionou....


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar