Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Responding to events in another form

Posted on 2004-10-13
2
Medium Priority
?
154 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 200 total points
ID: 12297141
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
ID: 12298440
beautiful man!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 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