• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

how to detect the mouse leave?

using vb4. Show tool tip when the mouse is over. however, if the mouse leaves a control quickly, the tooltip is still there. Any way to know when the mouse leave?
0
bobhshaw
Asked:
bobhshaw
1 Solution
 
DalinCommented:
bobhshaw,
Try this, let me know if you have any questions.
Regards
Dalin

In the form's general declaration area, add:

  Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
  Private Declare Function ReleaseCapture Lib "user32" () As Long

In the MouseMove Event of the control, add

Dim MouseOver As Boolean
' See if the mouse is over
MouseOver = (0 <= X) And (X <= Command2.Width) And (0 <= Y) And (Y <= Command2.Height)

If MouseOver Then
 MouseOver is true
        ' Do something
        SetCapture Command2.hWnd
  Else
   ' Mouse Left
         'Do something else
         ReleaseCapture
 End If
0
 
bobhshawAuthor Commented:
Thank you.
0
 
MirkwoodCommented:
Bought This Question.
0
 
smeggheadCommented:
Could someone tell me what the 'SetCapture' api does ??
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now