gpt4 book ai didi

delphi 覆盖 webbrowserH

转载 作者:行者123 更新时间:2023-12-02 01:34:10 26 4
gpt4 key购买 nike

我尝试制作一个定制的网络浏览器,它实际上是一个具有额外功能的 Twebbrowser:当页面在 30 秒内未加载时,它会调度一个 TimerOut 事件。

所以我在 TwebbrowsersTimerOut 中添加了一个继承自 Twebbrowser 的计时器。

这个想法是在 BeforeNavigate 或 DownloadBegin 事件上计时此计时器:并在 onDownloadComplete 事件上停止计数器。

问题是我不知道如何覆盖这些事件:以及更全面的如何覆盖现有组件的事件:有人可以帮助我覆盖 TwebBrowser 组件,特别是它的事件吗?

问候

最佳答案

一般来说,事件只是可以在自定义后代中设置的普通属性。您基本上可以拦截事件并提供自己的 Controller 。

例如,我刚刚创建了一个覆盖 OnExit 事件的组件...

interface

TmyWhatever = class(TWhateverAncestor)
private
fMyOnExit:TNotifyEvent
protected
procedure CustomOnExitEvent(Sender:TObject);
public
constructor Create(AOwner:TComponent); override;
published
//we provide our own OnExit event (to be set by the developer using this component)
property OnExit:TNotifyEvent read fMyOnExit write fMyOnExit
end;

implementation

constructor TmyWhatever.Create(AOwner:TComponent);
begin
inherited;

//setup our event in the parent
inherited OnExit := CustomOnExitEvent;
end;

procedure TmyWhatever.CustomOnExitEvent(Sender:TObject);
begin
//perhaps do custom work before the OnExit

//and then call the intercepted OnExit event, if needed
if Assigned(fMyOnExit) then
begin
fMyOnExit(Sender);
end;

//perhaps do custom work after the OnExit
end;

关于delphi 覆盖 webbrowserH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4230258/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com