Winform WebBrowser 获取鼠标当前坐标

WebBrowser 中是没有MouseMove 事件的。想获取鼠标在WebBrowser中的坐标位置需要另辟蹊径、方法如下

在窗体中加入Timer控件

            timer1.Tick+=new EventHandler(timer1_Tick);
            timer1.Start();
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (webBrowser1.Bounds.Contains(this.PointToClient(Cursor.Position)))
            {

                lbXY.Text = webBrowser1.PointToClient(Cursor.Position).ToString();
            }

        }

把获取的位置给lbXY,虽然代码不多,但也让我费了些周折。

原文地址:https://www.cnblogs.com/midcn/p/2631360.html