Link to home
Start Free TrialLog in
Avatar of MMathieson
MMathieson

asked on

How to tell when the mouse has moved outside the bounds of a Control

Hi All,
I've been trying to write a small program that uses a THintWindow to show a hint when the mouse is over a ListBox.  I already have the code for showing the hint when the mouse is over the ListBox but I am having problem with clearing the hint once the mouse moves outside the Listbox.  When the hint is displayed, I start a timer and when the OnTimer event is fired, I call the THintWindow.ReleaseHandle which clears the hint for me.

I can hear you all asking, but why am I not using the Application Hint?  Well, the Application Hint calls GetShortHint() which breaks up the hint when it reaches a binary OR symbol "|" and seeing how I want to display this symbol in the hint, I can't use the Applications Hint.  By displaying the Hint using a THintWindow, I can display anything I want.

Now, back to my problem.  Is there a way of determining when the mouse moves outside the bounds of the ListBox?  If I can work out when the mouse has moved outside the bounds, then I can call THintWindow.ReleaseHandle to clear the hint.

If anyone can think of a better way of displaying the hint then please let me know.

Thanks.
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Write the THintWindow.ReleaseHandle when the mouse move event of the form, or any component if it's contain the listbox (like panel)
ASKER CERTIFIED SOLUTION
Avatar of alanwhincup
alanwhincup

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MMathieson
MMathieson

ASKER

I thought of that but I was hoping to be able to get away without writing extra code for other events.  i.e. I would only need to put code in the ListBox.MouseMove event to show the hint.
Thanks Alan,
That's going to work well although I did get around my problem by using another timer.  When the second OnTimer event fired, I checked if the mouse was still over the ListBox.  If it wasn't, then I called THintWindow.ReleaseHandle