Solved

Responding to events in another form

Posted on 2004-10-13
2
148 Views
Last Modified: 2010-04-05
I have 2 forms in my  application.

FORM1 launches FORM2 which has a TButton.

What is the best way to enable code in FORM1 to respond to the click event of the TButton in FORM2?
0
Comment
Question by:ziche
2 Comments
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 50 total points
Comment Utility
at Form1's code:

type
  TForm1 = class(TForm);
  public
    ...
    procedure Form2ButtonClicked(Sender: TObject);
  end;

...

procedure TForm1.Form2ButtonClicked(Sender: TObject);
begin
  ShowMessage('Button at Form 2 clicked!');
end;

procedure TForm1.CreateForm2;
begin
  with TForm2.Create(Self) do
  begin
    Button1.OnClick := Form2ButtonClicked;
    Show;
  end;
end;
0
 

Author Comment

by:ziche
Comment Utility
beautiful man!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now