社区
C#
帖子详情
C# webBrowser 返回鼠标点击的位置如何写?
cannycsy
2009-01-19 12:06:44
C# webBrowser 返回鼠标点击的位置如何写?
webBrowser1.Document.Body.ScrollLeft
webBrowser1.Document.Body.ScrollTop
上面这两个只返回就是顶点0,如何加上鼠标点下的位置,对webBrowser1属性不了解.
...全文
653
12
打赏
收藏
C# webBrowser 返回鼠标点击的位置如何写?
C# webBrowser 返回鼠标点击的位置如何写? webBrowser1.Document.Body.ScrollLeft webBrowser1.Document.Body.ScrollTop 上面这两个只返回就是顶点0,如何加上鼠标点下的位置,对webBrowser1属性不了解.
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
cklvxd
2010-09-08
打赏
举报
回复
[Quote=引用 11 楼 xtmyd 的回复:]
private void webBrowser1_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser1.Document.MouseDown += new HtmlElementEventHandler(Document_Mo……
[/Quote]
为什么鼠标点一下,会相应两下;
例, 在MOuseUp里,加 count++, count每次会加2,为什么
幻影
2009-02-02
打赏
举报
回复
private void webBrowser1_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser1.Document.MouseDown += new HtmlElementEventHandler(Document_MouseDown);
WebBrowser1.Document.MouseMove += new HtmlElementEventHandler(Document_MouseMove);
WebBrowser1.Document.MouseUp += new HtmlElementEventHandler(Document_MouseUp);
}
private void Document_MouseDown(object sender, HtmlElementEventArgs e)
{
// Insert your code here.
}
private void Document_MouseMove(object sender, HtmlElementEventArgs e)
{
// Insert your code here.
}
private void Document_MouseUp(object sender, HtmlElementEventArgs e)
{
// Insert your code here.
}
tongget
2009-02-01
打赏
举报
回复
不能动态使用.
winner2050
2009-01-19
打赏
举报
回复
好像不行.
不过可以通过在窗体里面的鼠标事件得到,鼠标在窗体里面的位置.
qiqundelang
2009-01-19
打赏
举报
回复
路过
bizbuy
2009-01-19
打赏
举报
回复
在程序里也可以得到吗?鼠标应该用js在用户端比较好取吧
zgke
2009-01-19
打赏
举报
回复
private void Form1_Load(object sender, EventArgs e)
{
timer1.Tick+=new EventHandler(timer1_Tick);
timer1.Interval = 1;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
if (webBrowser1.Document != null && webBrowser1.Document.Body != null)
{
int _Left = webBrowser1.Document.Body.Parent.ScrollRectangle.X;
int _Right = webBrowser1.Document.Body.Parent.ScrollRectangle.Y;
Rectangle _Rect = webBrowser1.RectangleToScreen(new Rectangle(0, 0, webBrowser1.Width, webBrowser1.Height));
if (_Rect.Contains(Cursor.Position))
{
int _X = Cursor.Position.X - _Rect.X;
int _Y = Cursor.Position.Y - _Rect.Y;
if (_X >= 0 && _Y >= 0)
{
Point _MousePoint = new Point(_X + _Left, _Y + _Right);
this.Text = _MousePoint.ToString();
}
}
}
}
}
这个看看效果...
U2008
2009-01-19
打赏
举报
回复
;;
leonwan
2009-01-19
打赏
举报
回复
up
yulien
2009-01-19
打赏
举报
回复
ding
cg2003
2009-01-19
打赏
举报
回复
UP
cannycsy
2009-01-19
打赏
举报
回复
zgke ,6楼的,在没有加载网页进入就可以取到位置,但如果加载入网址后怎么取得呢?
C#
浏览器编程,学习使用
在“新建项目”对话框的项目类型窗口中选中“Visual
C#
”作为项目开发语言,在模板窗口中选中“Windows 应用程序”作为项目开发模板,在“名称”、“
位置
”编辑框中输入自己设定的项目名字和项目存储
位置
,本讲义...
C#
全能速查宝典
《
C#
全能速查宝典》共分为8章,分别介绍了
C#
语言基础、Windows窗体及常用控件、Windows高级控件、控件公共属性、方法及事件、数据库开发、文件、数据流与注册表、GDI+绘图技术和
C#
高级编程,共包含562个
C#
编程中常用...
vc++ 开发实例源码包
内含(重启、图片操作、ip操作、键盘与
鼠标
、客户端以及服务端、文件传输等实例源码) 多个VC++加密解密算法库(CRYPT++) 详细讲解了Crypt++的加密解密的使用以及其它的加密解密方法(例如base64加解密、哈希加...
C#
110,539
社区成员
642,577
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章