I'm looking for easy way to create TNotifyEvent hook/wrapper So I got an idea to create it as object to make stuff easier
But I have no idea how to attach / swap method pointers correctly... :/
Maybe anyone of You has done similar things before?
Here is the skeleton of my class
TNotifyEventHook = class
private
NotifyEvent: ???????;
OldProc, NewProc: ???????;
FContinueEventChain: Boolean;
procedure Wrapper(Sender: TObject);
public
constructor Create(OriginalNotifyEvent: ???????; ChainNotifyEvent???????);
destructor Destroy; override;
property ContinueEventChain: Boolean read FContinueEventChain write FContinueEventChain default True;
end;
constructor TNotifyEventHook.Create(OriginalNotifyEvent: ???????; ChainNotifyEvent: ???????);
begin
NotifyEvent := ??????? // save
OldProc := ???????
NewProc := ???????
NotifyEvent := ??????? // redirect NotifyEvent to Wrapper
end;
destructor TNotifyEventHook.Destroy;
begin
??????? // detach chain
end;
procedure TNotifyEventHook.Wrapper(Sender: TObject);
begin
if Assigned(NewProc) then
NewProc(Sender);
if FContinueEvenChain and Assigned(OldProc) then
OldProc(Sender);
end;
I'd be really grateful for help... Or maybe just better ideas?