Dim pCurpoint As POINTAPI Dim hwnd As Long Dim hdc As Long Dim r As Long GetCursorPos pCurpoint Label2.Caption = pCurpoint.x & "," & pCurpoint.y hwnd = WindowFromPoint(pCurpoint.x, pCurpoint.y) hdc = GetDC(hwnd) bkr = GetBkColor(hdc) ScreenToClient hwnd, pCurpoint r = GetPixel(hdc, pCurpoint.x, pCurpoint.y) If r = -1 Then BitBlt Picture1.hdc, 0, 0, 1, 1, hdc, pCurpoint.x, pCurpoint.y, vbSrcCopy r = Picture1.Point(0, 0) Else Picture1.PSet (0, 0), r End If Picture1.BackColor = r ReleaseDC hwnd, hdc 答案中还必须用这个函数,至少现在我还没发现更好的
因为这个函数在有的设备中不支持。
Dim hwnd As Long
Dim hdc As Long
Dim r As Long
GetCursorPos pCurpoint
Label2.Caption = pCurpoint.x & "," & pCurpoint.y
hwnd = WindowFromPoint(pCurpoint.x, pCurpoint.y)
hdc = GetDC(hwnd)
bkr = GetBkColor(hdc)
ScreenToClient hwnd, pCurpoint
r = GetPixel(hdc, pCurpoint.x, pCurpoint.y)
If r = -1 Then
BitBlt Picture1.hdc, 0, 0, 1, 1, hdc, pCurpoint.x, pCurpoint.y, vbSrcCopy
r = Picture1.Point(0, 0)
Else
Picture1.PSet (0, 0), r
End If
Picture1.BackColor = r
ReleaseDC hwnd, hdc
答案中还必须用这个函数,至少现在我还没发现更好的