[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Calling an Event Handler procedure manually..

Posted on 1997-10-21
9
Medium Priority
?
143 Views
Last Modified: 2010-04-04
Hi..
  I have an event handler procedure  TForm1.BitBtn2Click(Sender: TObject); I wish to be able to call this procedure in my program without needing BitBtn2 being clicked. In other words I just want to call it like a regular procedure. Can I do this? When I try to call it by just putting 'TForm1.BitBtn2Click' in my code, I get an error saying '( required'.

Cheers
  Shawn Halfpenny
0
Comment
Question by:aztec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1348540
Hi

Call it in one of your other form procedures as follows:
BitBtn2Click(nil);

Call it from a procedure that is not part of your form as follows:
Form1.BitBtn2Click(nil);

JB
0
 
LVL 4

Expert Comment

by:StevenB
ID: 1348541
 The 'Sender' parameter can be used so that several buttons can all use the same Click Method. The Sender identifies the button which actually performed the Click.
  You are recieving the '( Required Error' because you are not supplying a Sender. In JimBobs example the Sender supplied is Nil i.e. nothing.

  Steven
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 1348542
To simulate a click press, you can just call the 'Click' method of the button i.e. BitBtn2.Click.


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Odie
ID: 1348543
If you are in another event you might want to pass that event's sender:

BitBtn2Click(Sender);
0
 
LVL 1

Accepted Solution

by:
dvaline earned 50 total points
ID: 1348544
 You have two options...

1.  Place the code in your event handler in another function and call that function from you event, and call that function from the other function.

2.  Place this code in yourfunction to call the event
  {TForm1.BitBtn2Click(BitBtn2)}
0
 
LVL 4

Expert Comment

by:StevenB
ID: 1348545
 I think the question was soundly answered by JimBob, so I figured that he was due the points. Thats why I didn't provide an answer, just another comment, with a little extra information. It seems a little rude to jump in with an answer to a question which is simply an inferior summary of previous comments. I know where I think the points should go.

  Steven.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1348546
I agree with StevenB, naturally...    :-)

0
 

Author Comment

by:aztec
ID: 1348547
I didn't like dvaline's answer. JimBob gave a great answer which I used. I think you should give JimBob the points as I rate his
answer Excellent!

Shawn Halfpenny
0
 
LVL 4

Expert Comment

by:StevenB
ID: 1348548
Hmmm, but you've graded dvaline. Oh well.

Steven.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

656 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