GetCaretPos VB声明 
Declare Function GetCaretPos Lib "user32" Alias "GetCaretPos" (lpPoint As POINTAPI) As Long 
说明 
判断插入符的当前位置 
返回值 
Long,非零表示成功,零表示失败。会设置GetLastError 
参数表 
参数 类型及说明 
lpPoint POINTAPI,这个结构会随同插入符在窗口客户坐标系统中的位置载入;那个窗口是插入符的父窗口 

解决方案 »

  1.   

    发错了
    是:
    GetCursorPos VB声明 
    Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long 
    说明 
    获取鼠标指针的当前位置 
    返回值 
    Long,非零表示成功,零表示失败。会设置GetLastError 
    参数表 
    参数 类型及说明 
    lpPoint POINTAPI,随同指针在屏幕像素坐标中的位置载入的一个结构 
      

  2.   

    Public Type POINTAPI
            x As Long
            y As Long
    End TypePublic Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPublic Declare Function GetDC Lib "user32" (h As Long) As LongPublic Declare Function GetPixel Lib "gdi32" (h As Long, x As Long, y As Long) As Long    Dim hTempDC As Long
        Dim TempP As POINTAPI
        Dim TempC As Long
        
        hTempDC = GetDC(0)
        
        Call GetCursorPos(TempP)
        TempC = GetPixel(hTempDC, TempP.x, TempP.y)
        
        Call ReleaseDC(0, hTempDC)
        
      

  3.   

    Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
      

  4.   

    多谢了!不过我还是不太明白
    lpPoint POINTAPI,随同指针在屏幕像素坐标中的位置载入的一个结构 
    是什么意思?能详细说说吗
      

  5.   

    在你鼠标移动时, 用 GetCursorPos  函数,可以 随时取回 你鼠标在屏幕上的坐标位置。而这组坐标(包含X,Y轴)是封装在 POINTAPI 结构中的。
      

  6.   

    也就是说 把鼠标所在位置的信息放在lpPoint这个POINTAPI结构中
      

  7.   

    何需用API?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
      

  8.   

    楼上,你那代码只能在 Form 内而帖主问的:2. 还想请问一下,当鼠标在窗口以外是,有办法获得mousemove事件吗?
      

  9.   

    你说对了,我想做个功能更强大的,主要是我自己能用着方便,我想我需要的肯定是要调用API函数的
      

  10.   

    还有没有人知道怎么用API呀!
      

  11.   

    先取得当前鼠标位置,截屏,只取这个点的位图,在当前窗体放一个PICTUREBOX,用截屏的图像填充,然后再取得某一点的RGB
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Declare Function CloseClipboard Lib "user32" () As Long
    Private Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
      

  12.   

    好像可以直接创建设备场景,然后从这个设备场景中取RGB,具体你自己试试
        SourceDC = CreateDC("DISPLAY", 0, 0, 0)
        DestDC = CreateCompatibleDC(SourceDC)
        BHandle = CreateCompatibleBitmap(SourceDC, rWidth, rHeight)
        SelectObject DestDC, BHandle
        BitBlt DestDC, 0, 0, rWidth, rHeight, SourceDC, Lt, Top, &HCC0020
    lRGB=GetPixel (SourceDC ,0,0)
      

  13.   

    我忘了,大概是一个mouse hook的编程,我以前做过,看看还能找到源代码吗