Home All Groups Group Topic Archive Search About
Author
7 Jun 2009 8:02 PM
HardySpicer
I have a listbox with a list of commands. When I put the mouse over
each element I want a small text box to pop-up with help commands. I
dont' want to click the mouse - just overlay it.


Hardy

Author
7 Jun 2009 8:45 PM
Mike
HardySpicer wrote:
> I have a listbox with a list of commands. When I put the mouse over
> each element I want a small text box to pop-up with help commands. I
> dont' want to click the mouse - just overlay it.

You are talking about tool tips.

Here is a function to add to your form class:

     Private _tip As New System.Windows.Forms.ToolTip()
     Public Sub DynoTip( _
          ByVal sender As System.Object, _
          Byval Title as String, _
          Byval text as string)
         ' Set up the delays for the ToolTip.
         _tip.AutoPopDelay = 15000
         _tip.InitialDelay = 1000
         _tip.ReshowDelay = 500
         _tip.UseFading = True
         _tip.ShowAlways = True
         _tip.ToolTipTitle = title
         _tip.Show(text, _
                   sender, _
                   New System.Drawing.Point(0, sender.Height), 5000)
     End Sub

Usage:

     DynoTip(sender, "My Title", "text in box")

now, the trick for what you want is to probably going to require a
MouseHover or MoustCaptureChanged event over the listbox or as I just
tried the SelectedIndexChanged event with a CheckedListBox:

     Private Sub CheckedListBox1_SelectedIndexChanged( _
          ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles _
            CheckedListBox1.SelectedIndexChanged

         Dim i As Integer = CheckedListBox1.SelectedIndex
         If i >= 0 Then
             Dim title As String = _
                  CheckedListBox1.Items().Item(i).ToString
             BalloonTipIcon1.DynoTip(sender, title, _
                   "help for " + title)
         End If
     End Sub

If you want it to just to hover without any select, then you have to
play with the MouseHover and I can imagine that will be alittle tricky
to work out the IN/OUT timing.

That should get your started to fine tune it.

--
Author
7 Jun 2009 10:47 PM
gillardg
thank you it's very usefull

Show quoteHide quote
"Mike" <unkn***@unknown.tv> a écrit dans le message de groupe de discussion
: #uorjD75JHA.6***@TK2MSFTNGP02.phx.gbl...
> HardySpicer wrote:
>> I have a listbox with a list of commands. When I put the mouse over
>> each element I want a small text box to pop-up with help commands. I
>> dont' want to click the mouse - just overlay it.
>
> You are talking about tool tips.
>
> Here is a function to add to your form class:
>
>     Private _tip As New System.Windows.Forms.ToolTip()
>     Public Sub DynoTip( _
>          ByVal sender As System.Object, _
>          Byval Title as String, _
>          Byval text as string)
>         ' Set up the delays for the ToolTip.
>         _tip.AutoPopDelay = 15000
>         _tip.InitialDelay = 1000
>         _tip.ReshowDelay = 500
>         _tip.UseFading = True
>         _tip.ShowAlways = True
>         _tip.ToolTipTitle = title
>         _tip.Show(text, _
>                   sender, _
>                   New System.Drawing.Point(0, sender.Height), 5000)
>     End Sub
>
> Usage:
>
>     DynoTip(sender, "My Title", "text in box")
>
> now, the trick for what you want is to probably going to require a
> MouseHover or MoustCaptureChanged event over the listbox or as I just
> tried the SelectedIndexChanged event with a CheckedListBox:
>
>     Private Sub CheckedListBox1_SelectedIndexChanged( _
>          ByVal sender As System.Object, _
>          ByVal e As System.EventArgs) Handles _
>            CheckedListBox1.SelectedIndexChanged
>
>         Dim i As Integer = CheckedListBox1.SelectedIndex
>         If i >= 0 Then
>             Dim title As String = _
>                  CheckedListBox1.Items().Item(i).ToString
>             BalloonTipIcon1.DynoTip(sender, title, _
>                   "help for " + title)
>         End If
>     End Sub
>
> If you want it to just to hover without any select, then you have to play
> with the MouseHover and I can imagine that will be alittle tricky to work
> out the IN/OUT timing.
>
> That should get your started to fine tune it.
>
> --
Author
8 Jun 2009 1:47 AM
HardySpicer
On Jun 8, 8:45 am, Mike <unkn***@unknown.tv> wrote:
Show quoteHide quote
> HardySpicer wrote:
> > I have a listbox with a list of commands. When I put the mouse over
> > each element I want a small text box to pop-up with help commands. I
> > dont' want to click the mouse - just overlay it.
>
> You are talking about tool tips.
>
> Here is a function to add to your form class:
>
>      Private _tip As New System.Windows.Forms.ToolTip()
>      Public Sub DynoTip( _
>           ByVal sender As System.Object, _
>           Byval Title as String, _
>           Byval text as string)
>          ' Set up the delays for the ToolTip.
>          _tip.AutoPopDelay = 15000
>          _tip.InitialDelay = 1000
>          _tip.ReshowDelay = 500
>          _tip.UseFading = True
>          _tip.ShowAlways = True
>          _tip.ToolTipTitle = title
>          _tip.Show(text, _
>                    sender, _
>                    New System.Drawing.Point(0, sender..Height), 5000)
>      End Sub
>
> Usage:
>
>      DynoTip(sender, "My Title", "text in box")
>
> now, the trick for what you want is to probably going to require a
> MouseHover or MoustCaptureChanged event over the listbox or as I just
> tried the SelectedIndexChanged event with a CheckedListBox:
>
>      Private Sub CheckedListBox1_SelectedIndexChanged( _
>           ByVal sender As System.Object, _
>           ByVal e As System.EventArgs) Handles _
>             CheckedListBox1.SelectedIndexChanged
>
>          Dim i As Integer = CheckedListBox1.SelectedIndex
>          If i >= 0 Then
>              Dim title As String = _
>                   CheckedListBox1.Items().Item(i).ToString
>              BalloonTipIcon1.DynoTip(sender, title, _
>                    "help for " + title)
>          End If
>      End Sub
>
> If you want it to just to hover without any select, then you have to
> play with the MouseHover and I can imagine that will be alittle tricky
> to work out the IN/OUT timing.
>
> That should get your started to fine tune it.
>
> --

So I am guessing that I need an array of some sort with all my help
commands so I can index each one.
Works great! Thanks

Hardy
Author
8 Jun 2009 12:10 AM
Family Tree Mike
"HardySpicer" <gyansor***@gmail.com> wrote in message
news:cdc5be5d-a552-401d-93b4-e76d602e5e92@s16g2000vbp.googlegroups.com...
>I have a listbox with a list of commands. When I put the mouse over
> each element I want a small text box to pop-up with help commands. I
> dont' want to click the mouse - just overlay it.
>
>
> Hardy


Mike's solution is interesting.  Here would be the next step to that, in my
opinion.  I would do this:

Add an event handler for the listbox mousemove event in your constructor,
like this:
        AddHandler ListBox1.MouseMove, AddressOf MyTooltipHandler

Then have the handler coded like this:

    Public Sub MyTooltipHandler(ByVal sender As Object, ByVal mmea As
MouseEventArgs)
        Dim p As Point = Cursor.Position
        p = ListBox1.PointToClient(p)
        Dim idx As Integer
        idx = p.Y / ListBox1.ItemHeight
        If (idx < ListBox1.Items.Count) Then
            ToolTip1.SetToolTip(ListBox1, ListBox1.Items(idx))
        Else
            ToolTip1.SetToolTip(ListBox1, "Unkown")
        End If
    End Sub


--
Mike