Link to home
Start Free TrialLog in
Avatar of sellandbuy
sellandbuy

asked on

Writing method response to onclick

I have an application that creating some descendents of TShape during run time. I want to these objects that are created during run time to response to onclick method, how do i do that ? pls answer.
Avatar of rwilson032697
rwilson032697

You can use the OnMouseDown or OnMouseUp events. Just assign an event handler to the one you want when you create the TShape descendent.

Cheers,

Raymond.
Here is what you do...

form1 = class(TForm1)
...
private
  procedure MyHandler(Sender : TObject);
.......

var
  sh : TShape;
begin
  sh := TShape.Create;
  //Set Properties....
  sh.OnMouseUp := MyHandler;
end;

//Don't forget to free the object  when you are done with it...

procedure TFoirm1.MyHandler(Sender : TObject);
begin
  ShowMessage('You just clicked on the shape');
end;
well, why did you reject rwilson's answer? Any comments what more you ned or something?

Thank you!

-Viktor
--Ivanov
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

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 sellandbuy

ASKER

I thought viktornet gave me a better answer so....