小编PoY*_*oYo的帖子

在 WebBrowser 文档中获取鼠标点击坐标

我在 PictureBox 中捕获点击坐标,但我想用 WebBrowser 实现同样的目标。经过一番研究,我发现无法订阅ClickWebBrowser 控件的鼠标事件。
捕获点击的可能方法有哪些?是否有一种元素可以让我浏览页面但仍然捕获点击?

我尝试创建一个透明面板,但透明颜色并不意味着我看到的透明,并且当元素在后面时也不会捕获点击,如果面板位于 WebBrowser 后面,则能够捕获点击也可以.

图片框代码:

private void uploadedPNG_MouseClick(object sender, MouseEventArgs e)
{
    if(uploadedPNG.Image != null && !string.IsNullOrEmpty(deviceHeight.Text) && !string.IsNullOrEmpty(deviceWidth.Text))
    {
        mouseX = e.X;
        mouseY = e.Y;
        targetHeight = Int32.Parse(deviceHeight.Text);
        targetWidth = Int32.Parse(deviceWidth.Text);
        int outPutWidth = (mouseX * targetWidth) / uploadedPNG.Width;
        int outPutHeight = (mouseY * targetHeight) / uploadedPNG.Height;
        ConsoleText.Text = "Clicked X coordinate " + outPutWidth + " Clicked Y coordinate " + outPutHeight;
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# webbrowser-control winforms

4
推荐指数
1
解决办法
1195
查看次数

标签 统计

.net ×1

c# ×1

webbrowser-control ×1

winforms ×1