Board index » cppbuilder » How to change OnClick Event dynamically?

How to change OnClick Event dynamically?

Hi,

    I have a function the crearts a button dynamically on a TForm. My
problem is that I want to change the OnClick event of this button by
passing in a pointer to a function. I am not sure how to prototype my
function. The way my program is structured the new OnClick event has to
be passed in as one of the function parameters.

thanks,
Liam Mullane.

 

Re:How to change OnClick Event dynamically?


Hi, Liam!

The prototype is documented as TNotifyEvent in the help. Don't forget
this has to be a member function of your form class.

------
Mark Cashman, TeamB C++ Builder
http://www.temporaldoorway.com/programming/index.htm
C++ Builder, JBuilder programming information
Home of The C++ Builder Programmer's Webring - Join us!
------

Re:How to change OnClick Event dynamically?


Quote
"Liam Mullane" <lmull...@dairymaster.ie> wrote in message

news:3945FB02.7D465CF1@dairymaster.ie...

Quote
> Hi,

>     I have a function the crearts a button dynamically on a TForm. My
> problem is that I want to change the OnClick event of this button by
> passing in a pointer to a function. I am not sure how to prototype my
> function. The way my program is structured the new OnClick event has to
> be passed in as one of the function parameters.

I usually just try to get the IDE to prototype the event handlers for me
when I want to do that:
1)  Drop a throwaway button in your form.
2)  Add an OnClick handler to the button in the usually manner and code it.
3)  Delete the throwaway button from your form in the IDE.  If you have put
code in the OnClick event, the IDE will leave it alone.
4)  Add code to assign the event handler to your dynamic button:
    DynamicButton->OnClick = ThrowawayButtonClick;

John

Other Threads