Identificar formulario que me chamou ???
Pessoal , tenho um formulario ( busca_cliente ) a minha dúvida é o seguinte quero identificar em qual formulário q me chamou entende..
Estou usando esse código abaixo , mas de vez em quando ele da pau.
if key =13 then
begin
TituloObjeto := FindWindow(´TFrm_notas´, nil);
if TituloObjeto <> 0 then { Já está aberto }
begin
linha := StringGrid1.Row;
frm_notas.edit6.text := StringGrid1.Cells[0,linha];
frm_notas.edit4.text := StringGrid1.Cells[1,linha];
Close;
end;
TituloObjeto := FindWindow(´Tfrm_Cliente_re´, nil);
if TituloObjeto <> 0 then { Já está aberto }
begin
linha := StringGrid1.Row;
frm_Cliente_re.edit6.text := StringGrid1.Cells[0,linha];
frm_Cliente_re.edit4.text := StringGrid1.Cells[1,linha];
Close;
end;
TituloObjeto := FindWindow(´Tfrm_notas´, nil);
if TituloObjeto <> 0 then { Já está aberto }
begin
linha := StringGrid1.Row;
frm_notas.edit10.text := StringGrid1.Cells[0,linha];
frm_notas.edit9.text := StringGrid1.Cells[1,linha];
Close;
end;
end;
end;
Tem alguma forma melhor de se fazer isso ?
Valeu
Estou usando esse código abaixo , mas de vez em quando ele da pau.
if key =13 then
begin
TituloObjeto := FindWindow(´TFrm_notas´, nil);
if TituloObjeto <> 0 then { Já está aberto }
begin
linha := StringGrid1.Row;
frm_notas.edit6.text := StringGrid1.Cells[0,linha];
frm_notas.edit4.text := StringGrid1.Cells[1,linha];
Close;
end;
TituloObjeto := FindWindow(´Tfrm_Cliente_re´, nil);
if TituloObjeto <> 0 then { Já está aberto }
begin
linha := StringGrid1.Row;
frm_Cliente_re.edit6.text := StringGrid1.Cells[0,linha];
frm_Cliente_re.edit4.text := StringGrid1.Cells[1,linha];
Close;
end;
TituloObjeto := FindWindow(´Tfrm_notas´, nil);
if TituloObjeto <> 0 then { Já está aberto }
begin
linha := StringGrid1.Row;
frm_notas.edit10.text := StringGrid1.Cells[0,linha];
frm_notas.edit9.text := StringGrid1.Cells[1,linha];
Close;
end;
end;
end;
Tem alguma forma melhor de se fazer isso ?
Valeu
Michel
Curtidas 0
Respostas
Michel
23/01/2004
Pessoal tive q usar uma variavel pra sanar meu problema !
valeu :wink:
valeu :wink:
GOSTEI 0
Fabio.hc
23/01/2004
Tente assim:
Coloque este comando no form ( busca_cliente ) que vc quer saber quem foi que o chamou.
procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(´Quem me chamou foi o ´+Screen.Forms[1].Name); end;
Coloque este comando no form ( busca_cliente ) que vc quer saber quem foi que o chamou.
GOSTEI 0
Michel
23/01/2004
Fabio desse jeito ele ta pegando o formulario principal e nao o que chamou ele , eu estou precisando disso porque quando o usuario da um ( enter ) na Grid tenho q saber qual janela que chamou ele entende pra eu saber onde vou jogar os dados ( codigo, nome ). Por esse formulario meu de consulta pode ser usado por todos no sistema .
Valeu Fabio
Obrigado
Valeu Fabio
Obrigado
GOSTEI 0
Warplace
23/01/2004
Olha eu enfrentei um problema igual ao seu.
Então como não sabia resolver utilizei uma variável global que indica quem é o formulário que chama.
tipo assim:
declare a variável vchamador em uma unit utilizada por ambos os forms.
tipo variaveis.pas
no form1
uses variaveis;
vchamador := ´form1´;
form2.showmodal;
no form2
uses variaveis;
ShowMessage(´Quem me chamou foi o ´+vchamador);
Então como não sabia resolver utilizei uma variável global que indica quem é o formulário que chama.
tipo assim:
declare a variável vchamador em uma unit utilizada por ambos os forms.
tipo variaveis.pas
no form1
uses variaveis;
vchamador := ´form1´;
form2.showmodal;
no form2
uses variaveis;
ShowMessage(´Quem me chamou foi o ´+vchamador);
GOSTEI 0
Fabio.hc
23/01/2004
Tente assim:
Coloque este comando no form ( busca_cliente ) que vc quer saber quem foi que o chamou.
procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(´Quem me chamou foi o ´+Screen.Forms[1].Name); end;
Quando esta usando MDIForm:
procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(´Quem me chamou foi o ´+Screen.Forms[2].Name); end;
Obs:
O screen.forms guarda a lista de forms abertos sendo:
Screen.Forms[0] - o último form ativo
Screen.Forms[1] - o penúltimo form ativo
Screen.Forms[2] - o anti-penúltimo form ativo
...
GOSTEI 0