Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have one for you

Status
Not open for further replies.

john230873

Programmer
Oct 3, 2003
89
NZ
I have 2 forms (one main, one second). I what to have multiple second forms.
When the accept button is press on the second form then I want the second form to close and trigger a procedure in the first form.

Here is the code to create the form (note I have rerouted the
button's click procedure to the main form. The problem is a can't get the scond form to close


procedure TForm1.Button1Click(Sender: TObject);
begin
With TForm2.create(self) do
begin
Button1.OnClick := Showthemessage;
Show;
end;
end;

procedure TForm1.Showthemessage(Sender: TObject);
begin
showmessage('triggered');
end;



 
i dont understand

form1 creates form2
form2 closes and in the onclose event triggers form1.dosomething

whats the problem ??????????

Aaron Taylor
John Mutch Electronics
 
Try:

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 := Tform2.Create(self);
  With Form2 do
  begin
    Button1.OnClick := Form2.closeandtrigger;
    Show;
  end;
end;

procedure Tform1.pippo;
begin
  .........
  .........  
end;

-----------

procedure TForm2.closeandtrigger(Sender: TObject);
begin
  form1.pippo;
  close;
end;

Giovanni Caramia
 
I did think about the option of the second form triggering a procedure in the first form but I didn't think it was good programming practice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top