|
Картинка будет иметь цвет пикселя под курсором мышки. Не важно где находится курсор (на вашей форме или нет) TextBox покажет Hex-значение цвета. Добавьте элементы Timer, PictureBox и Text Box на форму Private Declare Function CreateDC& Lib "gdi32" Alias
"CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal
lpOutput As String, lpInitData As Any)
Private Declare Function DeleteDC& Lib "gdi32" (ByVal hdc 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 Type POINTAPI
x As Long
y As Long
End Type
Dim z As POINTAPI
Private Sub Form_Load()
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
GetCursorPos z
screendc = CreateDC("DISPLAY", "", "", 0&)
'замените текст Text1 = Hex(GetPixel(screendc, z.x, z.y))
'если вы хотите увидеть Hex-значение цвета
Text1 = GetPixel(screendc, z.x, z.y)
Picture1.BackColor = GetPixel(screendc, z.x, z.y)
DeleteDC (screendc)
End Sub
|
|