要用到API
首先要使用GetCursorPos,它可以取得当前mouse的座标。
使用GetPixel来得到一个像素
其中还要使用GetDC
有了这几个API 就可以实现了。
我做过这样一个东西,可以发给你,
不过是在vb.net下来的。

解决方案 »

  1.   


    Point 方法
          按照长整数,返回在 Form 或 PictureBox 上所指定磅的红-绿-蓝 (RGB) 颜色。不支持命名参数。语法object.Point(x, y)Point 方法的语法包含下列部分:部分 描述 
    object 可选的。一个对象表达式,其值为“应用于”列表中的一个对象。如果省略 object,带有焦点的 Form 象缺省为 object. 
    x, y 必需的。均为单精度值,指示 Form 或 PictureBox 的 ScaleMode 属性中该点的水平(x-轴)和垂直(y-轴)坐标。必须用括号包括这些值。 
    说明如果由 x 和 y 坐标所引用的点位于 object 之外,Point 方法将返回 -1。
    Point 方法示例
    本示例使用 Point 方法来确定一个窗体上的一个指定点的颜色。要检验此示例,可将本例代码粘贴到一个窗体的声明部分,然后按 F5 键并单击该窗体。Private Sub Form_Click ()
       Dim LeftColor, MidColor, Msg, RightColor   ' 声明变量。
       AutoRedraw = -1   ' 打开AutoRedraw。
       Height = 3 * 1440   ' 将高度设置为 3 英寸。
       Width = 5 * 1440   ' 将宽度设置为 5 英寸。
       BackColor = QBColor(1)   ' 将背景设置为蓝色。
       ForeColor = QBColor(4)   ' 将前景设置为红色。
       Line (0, 0)-(Width / 3, Height), , BF   ' 红框。
       ForeColor = QBColor(15)   ' 将前景设置为白色。
       Line (Width / 3, 0)-((Width / 3) * 2, Height), , BF
       LeftColor = Point(0, 0)   ' 查找左框颜色,,
       MidColor = Point(Width / 2, Height / 2)   ' 中框, 和
       RightColor = Point(Width, Height)   ' 右框。
       Msg = "The color number for the red box on the left side of "
       Msg = Msg & "the form is " & LeftColor & ". The "
       Msg = Msg & "color of the white box in the center is "
       Msg = Msg & MidColor & ". The color of the blue "
       Msg = Msg & "box on the right is " & RightColor & "."
       MsgBox Msg   ' 显示信息。
    End Sub
      

  2.   

    Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long 
    说明 
    在指定的设备场景中取得一个像素的RGB值 
    返回值 
    Long,指定点的RGB颜色。如指定的点位于设备场景的剪切区之外,则返回CLR_INVALID 
    参数表 
    参数 类型及说明 
    hdc Long,一个设备场景的句柄 
    x,y Long,逻辑坐标中要检查的点 
    注解 
    用GetDeviceCaps判断设备是否支持本函数