C# webBrowser 返回鼠标点击的位置如何写?webBrowser1.Document.Body.ScrollLeft
webBrowser1.Document.Body.ScrollTop上面这两个只返回就是顶点0,如何加上鼠标点下的位置,对webBrowser1属性不了解.
webBrowser1.Document.Body.ScrollTop上面这两个只返回就是顶点0,如何加上鼠标点下的位置,对webBrowser1属性不了解.
调试欢乐多
{
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();
}
} }
}
} 这个看看效果...
{
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.
}
为什么鼠标点一下,会相应两下;
例, 在MOuseUp里,加 count++, count每次会加2,为什么