I finally came up with a solution to a problem that someone posted, but I can't find them now. He wanted to have a control (an image, I think) change whenever the mouse was over it, then change back when the mouse left it. Here is code that creates a "MouseOver" event for any control on your form.

Paste the following into a standard module:
Code:
Option Explicit

Type POINTAPI
    X As Long
    Y As Long
End Type

Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Function GetControlRect(ControlIn As Control, FormIn As Form) As RECT
    GetControlRect.Left = (ControlIn.Left + FormIn.Left + 50) / _
        Screen.TwipsPerPixelX
    GetControlRect.Right = (ControlIn.Left + FormIn.Left + _
        ControlIn.Width + 50) / Screen.TwipsPerPixelX
    GetControlRect.Top = (ControlIn.Top + FormIn.Top + 325) / _
        Screen.TwipsPerPixelY
    GetControlRect.Bottom = (ControlIn.Top + FormIn.Top + _
        325 + ControlIn.Height) / Screen.TwipsPerPixelY
End Function

Public Function MouseOver(ControlIn As Control, FormIn As Form) As Boolean
    Dim CursorPos As POINTAPI
    Dim ControlRect As RECT

    GetCursorPos CursorPos
    ControlRect = GetControlRect(ControlIn, FormIn)
    
    If CursorPos.X > ControlRect.Left And _
        CursorPos.X < ControlRect.Right And _
        CursorPos.Y > ControlRect.Top And _
        CursorPos.Y < ControlRect.Bottom Then
            MouseOver = True
    Else
        MouseOver = False
    End If
End Function
Usage (Probably best used in a timer):

If MouseOver(ControlName, FormName) then
'Highlight control here
Else
'Unhighlight control here
End If

Example:
Place a timer, a picturebox, and two labels on a form (make sure the timer's Interval property is set to 10 or less for a quick response time). Then place the following code in the form's code window:
Code:
Option Explicit

Private Sub Timer1_Timer()
    If MouseOver(Label1, Me) Then
        Label2 = "You're over the label"
    ElseIf MouseOver(Picture1, Me) Then
        Label2 = "You're over the picture"
    Else
        Label2 = "You aren't over any controls"
    End If
End Sub
Hope that helps!

~seaweed

Edited by seaweed on 02-23-2000 at 04:56 PM