Delphi Two methods for Onmessage

Asked

Viewed 64 times

-2

In Delphi, it is possible to set two methods for the event OnMessage of TApplication?

Detail: both should work simultaneously.

Ex.:

TApplication.OnMessage := MetodoA();
TApplication.OnMessage := MetodoB();

2 answers

3

In Delphi it is not possible to assign more than one method to the same event. One way to circumvent this deficiency is to make a MetodoAB() and reference it at the event:

procedure MetodoAB();
begin
  MetodoA();
  MetodoB();
end;

TApplication.OnMessage := MetodoAB();

1

It is not possible, since the event properties are usually a Procedure of Object, which is basically a pointer to the method. You can create a third method that calls the first two and assign this in the event.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.