如果我在表单上使用以下组件WebBrowser1: TMyWebBrowser;
,并且如果我放在表单上OnDocumentComplete = WebBrowser1DocumentComplete
,TMyWebBrowser.DocumentComplete
即使WebBrowser1DocumentComplete
过程为空也不会触发。
我能开火的唯一方法TMyWebBrowser.DocumentComplete
就是拥有OnDocumentComplete = nil
.
任何人都可以解释我为什么?谢谢山姆
type
TMyWebBrowser = class(TWebBrowser)
private
{ Private declarations }
protected
{ Protected declarations }
procedure DocumentComplete(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
public
{ Public declarations }
Completed: Boolean;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure NavigateUntilCompleted(URL: String);
published
{ Published declarations }
End;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sam', [TMyWebBrowser]);
end;
constructor TMyWebBrowser.Create(AOwner: TComponent);
begin
inherited;
onDocumentComplete := DocumentComplete;
end;
procedure TMyWebBrowser.DocumentComplete(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
// check that the event is raised for the top-level browser (not frames or iframes)
if pDisp = TMyWebBrowser(ASender).ControlInterface then
begin
Completed := TRUE;
end;
inherited;
end;