delphi 覆盖 webbrowserH

标签 delphi twebbrowser

我尝试制作一个定制的网络浏览器,它实际上是一个具有额外功能的 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/

相关文章:

windows - 如何在Windows主题下使用Delphi显示一个 "greyed-out"只读复选框

delphi - Delphi 函数(或 Pascal)的默认返回值

delphi - 为什么在 TWebBrowser 中从未调用 ommouseenter 事件(已安装 IE9)

delphi - 有没有办法在 Delphi Firemonkey 中禁用 TWebBrowser 的右键单击

delphi - 事件没有被解雇

delphi - 如何确定所有单元的依赖关系? (估计重构成本)

delphi - 在不使用 TDatabase 绕过的情况下禁用登录提示

delphi - Redmon 和使用 Delphi 捕获标准输入

browser - 一个无需 GUI 的浏览器