Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How to clear Event Method at run-time?
Fri, Aug 12 2016 7:59 PMPermanent Link

Trinione

How can a components Event Method be set to nothing?

Basically, the opposite of assigning a method at run-time via the OnClick = OnClickHandler.

OnClick := nil     // does not work.
Sat, Aug 13 2016 4:15 AMPermanent Link

Emin

Trinione,

They all work as expected.
At what stage you are trying to set OnClick.
May be you are doing it before the component loading stage so that your assignments are overridden.

Emin Borbor

procedure TForm1.NewHandlerForClick(Sender: TObject);
begin
  ShowMessage('NewHandlerForClick', '');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('Button1Click', '');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Button1.OnClick := nil;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Button1.OnClick := NewHandlerForClick;
end;
Sat, Aug 13 2016 6:20 AMPermanent Link

Trinione

<< They all work as expected. >>

Emin:
Yes, it works. My error was I forgot to chamne the parameter of the function from a TControl to a TForm. As the event method (OnAnimationComplete) does not exist for a TControl the error occured.

Thanks you,
Trinione,
Image