Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function FindWindow _
Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetDC _
Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function GetPixel _
Lib "gdi32.dll" ( _
ByVal hDC As Long, _
ByVal X As Long, _
ByVal Y As Long) As Long
'Private Declare Function SetPixel _
Lib "gdi32.dll" ( _
ByVal hDC As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal crColor As Long) As Long
Private Declare Function GetCursorPos _
Lib "user32.dll" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient _
Lib "user32.dll" ( _
ByVal hWnd As Long, _
lpPoint As POINTAPI) As Long
Private ihWnd As Long, ihDC As Long, iPoint As POINTAPI
Private Sub UserForm_Initialize()
ihWnd = FindWindow(vbNullString, Me.Caption)
ihDC = GetDC(ihWnd)
End Sub
Private Sub Image1_Click()
GetCursorPos iPoint
ScreenToClient ihWnd, iPoint
Me.Caption = GetPixel(ihDC, iPoint.X, iPoint.Y)
'SetPixel ihDC, iPoint.X, iPoint.Y, vbRed 'проверка
End Sub
Помогите с функцией GetPixel в VBA
Когда-то, давным-давно, я решил поставленную задачу следующим образом :
Спасибо, я попробую
Выдает "-1" для всех цветов. Кстати аналогичное получается если просто задавать там вместо ihDc Image.Picture...
Win98/ME + Office97
WinXP + OfficeXP
У меня 10-ка... но цвет-то все равно не определяется(
P.S. OS не указали ;)
OS - Windows 7-ка.