Автор: James D. Rofka
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
protected
procedure MyMessages(var Msg: TMsg; var Handled: Boolean);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MyMessages;
end;
procedure TForm1.MyMessages(var Msg: TMsg; var Handled: Boolean);
var
X, Y: Integer;
document, E: OleVariant;
begin
Handled := False;
if (WebBrowser1 = nil) or (Msg.message <> WM_LBUTTONDOWN) then
Exit;
Handled := IsDialogMessage(WebBrowser1.Handle, Msg);
if (Handled) then
begin
case (Msg.message) of
WM_LBUTTONDOWN:
begin
X := LOWORD(Msg.lParam);
Y := HIWORD(Msg.lParam);
// document := WebBrowser1.document;
// E := document.elementFromPoint(X, Y);
ShowMessage('You clicked on:' + #10);// + E.outerHTML);
end;
end;
end;
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
protected
procedure MyMessages(var Msg: TMsg; var Handled: Boolean);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MyMessages;
end;
procedure TForm1.MyMessages(var Msg: TMsg; var Handled: Boolean);
var
X, Y: Integer;
document, E: OleVariant;
begin
Handled := False;
if (WebBrowser1 = nil) or (Msg.message <> WM_LBUTTONDOWN) then
Exit;
Handled := IsDialogMessage(WebBrowser1.Handle, Msg);
if (Handled) then
begin
case (Msg.message) of
WM_LBUTTONDOWN:
begin
X := LOWORD(Msg.lParam);
Y := HIWORD(Msg.lParam);
// document := WebBrowser1.document;
// E := document.elementFromPoint(X, Y);
ShowMessage('You clicked on:' + #10);// + E.outerHTML);
end;
end;
end;
end;