Link to home
Start Free TrialLog in
Avatar of ttheimer
ttheimer

asked on

How to share an event handler between forms?

I have event handler code in one form of an application that I would like to use for a component event in another form of the application.  

Each of the forms lists each other in the uses statement. but I can't see handlers from the other form in an event dropdown in the object inspector and if I type in the name of the procedure (<other_form_name>.<proc_name>) I receive an IDE error that the name is not a valid identifier.

Thanks.
Avatar of SteveBay
SteveBay
Flag of United States of America image

That's right. You need to make the event handler assignment at runtime.
ASKER CERTIFIED SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ttheimer
ttheimer

ASKER

TheRealLoki

I was able to define the event handlers upon execution using the second half of your answer.  

I tried setting up as described in the first half but never got it to work.  It made sense and I went back to check my setup but then ran out of time for further testing.  I will probably come back to this when more free time is available so I would be interested if this is a tested solution or a theory.

Thanks.
Tom