In the declaration of TForm1 you have to declare the procedure with exactly the same signature:
TForm1 = class(TForm)
procedure BlahBlah;
...
private
...
public
procedure OnEv(Sender: TObject);
end;
Only then can you write in some other TForm1 methodSomeVar.OnEvent := @onEv;
BTW, what you call TMyEvent is called TNotifyEvent everywhere else in the LCL.
Why the duplication?
Thx for your reply, howardpc.
Duplication is just for example.
Maybe i m bad to understand my problem. Your reply about blahblah procedure unclear for me.
I meant that I would like to use the inherited type of class as Event param, but compiller gives me error.
Maybe a real example is better.
I use LNet component TLTcp in console application.
There is OnReceive event in this class. And as param in that procedure(event) have (aSocket : TLSocket).
I have inherited class TMySocket from TLSocket whit some new properties and methods.
And when i want to declare OnReceive event with my class as param, i got error.
I can do this
procedure TSomeApplication.OnReceive(aSocket : TLsocket);
var
t : TMySocket;
begin
t := TMySocket(aSocket);
...
end;
but, its not elegant from me. Is there any way to do this right?