Re: TWebBrowser questions
From: Alex Taylor (basswar_at_vnet.hu)
Date: 05/18/04
- Next message: Tim: "Turbopower OnGuard"
- Previous message: Atozed Software: "IntraWeb 7.1 Released"
- In reply to: Davids: "TWebBrowser questions"
- Next in thread: Davids: "Re: TWebBrowser questions"
- Reply: Davids: "Re: TWebBrowser questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 May 2004 08:28:58 +0200
TWebBrowser already has the standard mouse and keyboard events
implemented but they are not published. You can simply publish it and
they will be available. Here is the source:
unit MyWebBrowser;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, SHDocVw;
type
TMyWebBrowser = class(TWebBrowser)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
Constructor Create(AOwner:TComponent);Override;
published
{ Published declarations }
Property OnMouseMove;
Property OnMouseDown;
Property OnMouseUp;
Property OnClick;
Property OnDblClick;
Property OnKeyDown;
Property OnKeyUp;
end;
procedure Register;
implementation
Constructor TMyWebBrowser.Create(AOwner:TComponent);
Begin
Inherited;
ControlStyle:=ControlStyle-[csNoStdEvents];
ControlStyle:=ControlStyle+[csCaptureMouse,csClickEvents,csDoubleClicks];
End;
procedure Register;
begin
RegisterComponents('MyComp', [TMyWebBrowser]);
end;
end.
This doesn't ensure the browser to not respond to any anchor click, but
you can try customize this. However you can access all the links with
the WebBrowser.ControlInterFace.Document.Links reference. The
WebBrowser.ControlInterFace.Document is an IDispatch interface and all
the DOM interfaces can be accessed thru it. The
WebBrowser.ControlInterFace.Document is referencing the currently loaded
document. So you can populate your listbox with all the links in the
following manner:
Var I:Integer;
Links:Variant;
Begin
Links:=WebBrowser.ControlInterFace.Document.Links;
For I:=0 to Links.length-1 do
Begin
ListBox.Items.Add(Links.item(I).innerText);
End;
End;
Regards:Alex
- Next message: Tim: "Turbopower OnGuard"
- Previous message: Atozed Software: "IntraWeb 7.1 Released"
- In reply to: Davids: "TWebBrowser questions"
- Next in thread: Davids: "Re: TWebBrowser questions"
- Reply: Davids: "Re: TWebBrowser questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|