Private Sub Command1_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
DisplayButtonMessage Command1, "Command 1"
End Sub
' If we are not already displaying a message,
' display it and enable the timer to see when
' the mouse moves off of it.
Private Sub DisplayButtonMessage(ByVal cmd As _
CommandButton, ByVal txt As String)
' See if we are already displaying a message.
If Timer1.Enabled Then Exit Sub
' Calculate the button's screen coordinates.
upper_left.X = ScaleX(cmd.Left, ScaleMode, vbPixels)
upper_left.Y = ScaleY(cmd.Top, ScaleMode, vbPixels)
ClientToScreen hwnd, upper_left
lower_right.X = ScaleX(cmd.Left + cmd.Width, ScaleMode, _
vbPixels)
lower_right.Y = ScaleY(cmd.Top + cmd.Height, ScaleMode, _
vbPixels)
ClientToScreen hwnd, lower_right
' Display the message and enable the timer.
lblStatus.Caption = txt
Timer1.Enabled = True
End Sub
' See if the cursor has moved off the button.
Private Sub Timer1_Timer()
Dim pt As POINTAPI
' Get the cursor position.
GetCursorPos pt
' See if the mouse is over the button.
If pt.X < upper_left.X Or pt.X > lower_right.X Or _
pt.Y < upper_left.Y Or pt.Y > lower_right.Y _
Then
' It is no longer over the button.
Timer1.Enabled = False
lblStatus.Caption = ""
End If
End Sub
|