|
-
Jan 19th, 2016, 10:10 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] ToolTip issue
Hi all.
I'm making a control and I'm having issue with tooltip behavior. My control inherits a picturebox, and depending on where the cursor lays, the toolTip help should not be the same. I've manage to make the basic concept work, but where I'm having an issue is when the mouse cursor moves 'within' my control. Since the mouse is not exiting the control the tooltip bubble is associated to, it just lays there where it was initially displayed. My process does call the SetToolTip method when the mouse it moved and then hover again over my control (without exiting it, as I said), but that doesn't seem to reset the tooltext bubble.
I know there is a hide method for the ToolTip class, but for some reason Microsoft decided to make this one as complicated as possible (it needs a IWin32Window parameter. Couldn't just make it 'Hide()', noooooo, of course... ) Tried to searched for examples on how to use IWin32Window interface, but I can't believe I have to create a wrapper class that implements IWin32Window just to hide my damn ToolTip bubble!
Please help.
Thanks in advance!
Don't ask why, just reboot!
-
Jan 19th, 2016, 10:50 PM
#2
Re: ToolTip issue
I find the easiest way to reset it, is to first set it to blank, then to a new value.
-tg
-
Jan 19th, 2016, 11:02 PM
#3
Re: ToolTip issue
 Originally Posted by Alain
I know there is a hide method for the ToolTip class, but for some reason Microsoft decided to make this one as complicated as possible (it needs a IWin32Window parameter. Couldn't just make it 'Hide()', noooooo, of course... ) Tried to searched for examples on how to use IWin32Window interface, but I can't believe I have to create a wrapper class that implements IWin32Window just to hide my damn ToolTip bubble!
You already have a class that implements IWin32Window: Control. If you've read about the IWin32Window interface then you know that it provides a Handle property that exposes the window's HWND. That's where the Control.Handle property, which allows you to make Windows API calls affecting that window, comes from. As the documentation for the ToolTip.Hide method states:
The Hide method hides the ToolTip for the specified Control if it is currently being displayed.
-
Jan 20th, 2016, 07:49 AM
#4
Thread Starter
Fanatic Member
Re: ToolTip issue
Thanks guys. A combination of both your answers (sort of) made it work.
 Originally Posted by jmcilhinney
You already have a class that implements IWin32Window: Control.
That I didn't know. Although I did read the documentation about IWin32Window, it did not mention that every control implements it (that said, it was late and I was tired, so I may have missed it...).
Here's the code that made it work:
Code:
Public Sub SetToolTipText(ToolTipText As String)
Me.ToolTipHelp.Hide(Me)
Me.ToolTipHelp.Show(ToolTipText, Me)
End Sub
"Me" is my control, which carries a ToolTip object accessible by the ToolTipHelp property.
Thanks again, and have a great day!
Don't ask why, just reboot!
-
Jan 20th, 2016, 09:57 AM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] ToolTip issue
Well, it appears I declared victory a tad too soon.
When my process calls the ShowToolTipText sub, the tooltip 'may or may not' be displayed. More so, it will sometimes be displayed on the mouse previous position, with the previous text (and I've checked that the proper text is passed in parameter using the Console as a debug output).
More so, I call the ShowToolTipText sub following a Hit test based on the mouse position, which itself is triggered by the MouseHover event. Well, that event does not seem to trigger in a stable and predictable manner when the mouse cursor stays over the same control. It triggers the first time the mouse enters the control (and hovers for a short time), and then if you move the mouse over the control again (without exiting it), and hover over it again, the MouseHover event 'may or may not' trigger (mostly not...).
I think I'm going to move on with an alternative solution, like displaying the ToolTiptext in a status bar at the bottom of the form that holds my control.
Bummer.
Last edited by Alain; Jan 20th, 2016 at 10:00 AM.
Don't ask why, just reboot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|