Results 1 to 5 of 5

Thread: [RESOLVED] ToolTip issue

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    527

    Resolved [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!

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: ToolTip issue

    I find the easiest way to reset it, is to first set it to blank, then to a new value.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ToolTip issue

    Quote Originally Posted by Alain View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    527

    Re: ToolTip issue

    Thanks guys. A combination of both your answers (sort of) made it work.

    Quote Originally Posted by jmcilhinney View Post
    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!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    527

    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
  •  



Click Here to Expand Forum to Full Width