-
Hi,
I need to simply tell the computer the area and have it tell me what object is there. how can I do that?
.......................
Something like this:
Picture(12).left + picture(12).width + 200, Picture(12).top + picture(12).top + 300 = where picture(13) is.
can I do that? thankyou!!
-
Add a Timer to your Form with some Controls..
Code:
Private Type POINTAPI
x As Long
y As Long
End Type
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 Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim tPOS As POINTAPI
Call GetCursorPos(tPOS)
Call ScreenToClient(hwnd, tPOS)
Caption = FindObject(ScaleX(tPOS.x, vbPixels, vbTwips), ScaleY(tPOS.y, vbPixels, vbTwips))
End Sub
Private Function FindObject(ByVal x As Single, ByVal y As Single) As String
On Error GoTo ObjErr
For Each Control In Me
If Control.Left <= x And Control.Top <= y Then
If (Control.Left + Control.Width) >= x And (Control.Top + Control.Height) >= y Then
FindObject = Control.Name
Exit For
End If
End If
ObjErr:
Next
End Function
Run the Form and Point to some Controls to see its Name.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net