关于在webbrowse中捕获鼠标点击事件的问题 (100分)

  • 主题发起人 主题发起人 ibeyond
  • 开始时间 开始时间
I

ibeyond

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在webbrowse中捕获鼠标事件?我主要是想得到鼠标点击的当前屏幕位置的坐标,
包括鼠标左键和鼠标右键.
 
如果不能直接在WebBrowser中捕获鼠标位置,可以试试用其它的方法,比如把WebBrowser控件放在其它的可以捕获鼠标位置的控件中。
 
我觉得webbrowser应该可以捕获鼠标事件的.因为我用vb可以实现.
 
这里有个组件可以很容易做到
TWebEvent
相关下载: http://new.playicq.com/dispdocnew.php?id=5018
下面是个例子,在当前窗口的标题中显示鼠标在WebBrowser控件中的位置
你自己可以添加任何事件,可以捕捉大多数html标记的事件
最新的组件源码可以向我索取

object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 12
object WebBrowser1: TWebBrowser
Left = 16
Top = 8
Width = 441
Height = 225
TabOrder = 0
OnDocumentComplete = WebBrowser1DocumentComplete
ControlData = {
4C000000942D0000411700000000000000000000000000000000000000000000
000000004C000000000000000000000001000000E0D057007335CF11AE690800
2B2E126208000000000000004C0000000114020000000000C000000000000046
8000000000000000000000000000000000000000000000000000000000000000
00000000000000000100000000000000000000000000000000000000}
end
object WebEvent1: TWebEvent
OnEvent = WebEvent1Event
WebEvents = <>
Left = 16
Top = 240
end
end

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, WebEvent, MsHtml;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
WebEvent1: TWebEvent;
procedure FormCreate(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
procedure WebEvent1Event(Sender: TWebBrowser; event,
SrcElement: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;

var
form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.playicq.com');
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
WebEvent1.EvtSource := WebBrowser1;
WebEvent1.EventsToFire := 'onmousemove';
WebEvent1.StandardTags := 'document';
WebEvent1.AttachEvents;
end;

procedure TForm1.WebEvent1Event(Sender: TWebBrowser; event,
SrcElement: OleVariant);
begin
Caption := IntToStr(event.x) + ',' + IntToStr(event.y);
end;

end.

 
我想知道,原本delphi没有相应的控件或者类支持这个特性?不可能吧,再顶.
 
vb怎么实现的,说一下。
 
Dim WithEvents Webdoc As HTMLDocument
这个Webdoc的所有事件就都可以捕获了.
 
虽然没有人给我解决,但是还是谢谢大家.
 
后退
顶部