Text Popup

H

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
 
M

Mike

HardySpicer said:
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.

--
 
G

gillardg

thank you it's very usefull

Mike said:
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.

--
 
F

Family Tree Mike

HardySpicer said:
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
 
H

HardySpicer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top