参考代码
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI '定义点(Point)结构
X As Long '点在X坐标(横坐标)上的坐标值
Y As Long '点在Y坐标(纵坐标)上的坐标值
End Type
Dim p As POINTAPI
GetCursorPos p
Me.Caption = p.X & "," & p.Y
For Each obj In Controls
If (p.X > (Me.Left + obj.Left) \ 15 And p.X < (Me.Left + obj.Left + obj.Width) \ 15) And (p.Y > (Me.Top + obj.Top) \ 15 And p.Y < (Me.Top + obj.Top + obj.Height) \ 15) Then '不好意思,象素和缇不知道咋转换。。
MsgBox obj.Name
Exit For
End If
Next
Private Sub Form_Load()
pRect.Left = Picture1.Left
pRect.top = Picture1.top
pRect.right = pRect.Left + Picture1.Width
pRect.buttom = pRect.top + Picture1.Height
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > pRect.Left And X < pRect.right And Y > pRect.top And pRect.buttom Then
Picture1.ToolTipText = "在Picture1内"
End If
End Sub