Board index » cppbuilder » Assigning Event Handlers for dynamically created components

Assigning Event Handlers for dynamically created components

Hi all.

Pardon me, my shiny newness is showing....

I've created an application that draws a graph on a TImage
embedded in a TPanel on a form. An Image1MouseDown()
function handles what to do if the user clicks on the TImage.
Everything worked great so long as I used the original TImage
dropped on the form at design time.

But resizing the form caused some display problems, so now,
in the event of a resize, I delete the original TImage and create
a new one, sized to match the new panel size. My graph then
redraws on the new TImage. Everything works great...

... except...

My Image1MouseDown() function never fires on the new
TImage. What do I have to do to assign the event handlers
to the new instance of TImage?

Thanks

Kevan

 

Re:Assigning Event Handlers for dynamically created components


Quote
knave wrote in message <8nejob$...@bornews.borland.com>...
>But resizing the form caused some display problems, so now,
>in the event of a resize, I delete the original TImage and create
>a new one, sized to match the new panel size. My graph then
>redraws on the new TImage. Everything works great...

>... except...

>My Image1MouseDown() function never fires on the new
>TImage.

Just assign it.

image->OnMouseDown = Image1MouseDown;

Harold Howe [TeamB]
http://www.bcbdev.com

Re:Assigning Event Handlers for dynamically created components


Duh!

Well THAT was easy enough. "Too simple, perhaps, for these troubled
times" <Gandalf>

Thanks Harold!

Quote
> Just assign it.

> image->OnMouseDown = Image1MouseDown;

> Harold Howe [TeamB]
> http://www.bcbdev.com

Other Threads