Fórum Identificar formulario que me chamou ??? #208883
23/01/2004
0
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
Curtir tópico
+ 0Posts
23/01/2004
Michel
valeu :wink:
Gostei + 0
24/01/2004
Fabio.hc
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
24/01/2004
Michel
Valeu Fabio
Obrigado
Gostei + 0
24/01/2004
Warplace
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
24/01/2004
Fabio.hc
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
Clique aqui para fazer login e interagir na Comunidade :)