Eduardo
Forgive me, but for "quick consumption" purposes, I've posted your code below
There's also this bit (strictly speaking, not code)Code:Option Explicit Private Type POINTAPI X As Long Y As Long End Type Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer 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 ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Sub Timer1_Timer() Dim iPt As POINTAPI Dim iColor As Long Dim iHwnd As Long Dim iDc As Long If (GetAsyncKeyState(vbKeyLButton) < 0) Then GetCursorPos iPt iHwnd = WindowFromPoint(iPt.X, iPt.Y) If IsLocal(iHwnd) Then ScreenToClient iHwnd, iPt iDc = GetDC(iHwnd) If iDc <> 0 Then iColor = GetPixel(iDc, iPt.X, iPt.Y) If iColor > -1 Then Picture1.BackColor = iColor End If End If End If End If End Sub Private Function IsLocal(nHwnd As Long) As Boolean Dim iCtl As Control Dim iHwnd As Long If nHwnd = Me.hWnd Then IsLocal = True Else On Error Resume Next For Each iCtl In Me.Controls iHwnd = iCtl.hWnd If iHwnd = nHwnd Then IsLocal = True Exit For End If Next End If End Function
Looks interesting ..Code:Begin VB.Timer Timer1 Interval = 50 Left = 144 Top = 288 End
Spoo




Reply With Quote