Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long Private Type POINTAPI x As Long y As Long End Type Private Sub Timer1_Timer() Dim a As Long Dim pp As POINTAPI Dim dd As Long a = GetDC(0) GetCursorPos pp dd = GetPixel(a, pp.x, pp.y) Text1.Text = Abs(dd And &HFF) Text2.Text = Abs(dd And 65280) / 256 Text3.Text = Abs(dd And &HFF0000) / 65536 ReleaseDC Me.hwnd, a End Sub
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Dim a As Long
Dim pp As POINTAPI
Dim dd As Long
a = GetDC(0)
GetCursorPos pp
dd = GetPixel(a, pp.x, pp.y)
Text1.Text = Abs(dd And &HFF)
Text2.Text = Abs(dd And 65280) / 256
Text3.Text = Abs(dd And &HFF0000) / 65536
ReleaseDC Me.hwnd, a
End Sub