我正在寻找创建 TNotifyEvent 钩子/包装器的简单方法所以我想到了将它创建为对象以使事情变得更容易
但我不知道如何正确附加/交换方法指针......:/
也许你们中的任何人以前做过类似的事情?
这是我班的骨架
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;
我真的很感激帮助......或者也许只是更好的想法?