【问题标题】:how to get co-ordinates of pixel by clicking on it如何通过单击获取像素坐标
【发布时间】:2011-05-27 13:14:20
【问题描述】:

我是 C# 和 .net 的新手。我想通过点击它来获取像素的坐标,这样它应该显示在工具提示中!!我有一个获取顶点的代码,但我不知道如何与鼠标点击相关联。

public class Vertex
    {
        public Vertex(int i, int j)
        {
            this.X = i;
            this.Y = j;
        }
         public int X { get; set; }
         public int Y { get; set; }
         public string ToString()
        {
            return string.Format("({0}/{1})", this.X, this.Y);
        }
    }  

【问题讨论】:

  • 你想在 Windows 窗体或 aspx 页面中获取鼠标坐标吗?
  • @kalyan .. 我想在 Windows 窗体上获取位图坐标(不知道它们是否称为鼠标坐标)。有显示位图的扩展图片框,我想要弹出窗口(工具提示)显示在那里。

标签: visual-studio-2010 c#-4.0 bitmap tooltip pixel


【解决方案1】:

WindowsForms 中处理鼠标按下事件。 MouseEventArgs 的 msdn 页面提供了在工具提示中显示坐标的示例。

编辑: 只是关于要记住的事情的注释。 MouseEventArgs 中的坐标可能因您正在处理的事件而异(请参阅前面引用的鼠标事件参数 msdn 页面)。在某些情况下,Location 与控件相关,在其他情况下与表单相关,而在其他情况下与屏幕相关。

【讨论】:

    猜你喜欢
    • 2012-11-26
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 2021-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多