PDA

View Full Version : Clean way to create popup help balloons



PCMonitor
01-14-2007, 06:02 PM
I am on the hunt for a good/easy way to generate a "help balloon" when i mousemove over a text label (a textlabel on my VBA form) and then disappear by timer, I assume thats thats the most pain free method?

Ken Puls
01-14-2007, 06:22 PM
I assume that you just want static help for those labels?

Go into the userform, click your label, and enter something in the ControlTipText field of the Properties window. That should give you the effect you want, no code needed.

It can, of course, be changed at run time by modifying the ControlTipText property as well.

HTH,

PCMonitor
01-14-2007, 07:11 PM
Yeah thanks thats easy enough, do you mean that i can make the control tip stay on screen for longer?

Ken Puls
01-14-2007, 11:56 PM
Not that I'm aware of, no. This will show the tip so long as the user hovers their mouse over it, but then it goes away.

If you want to time it out longer, you could try using an API to capture a "MouseOver" event, but it may be way more pain than it's worth. Does depend on your application and reasons, though.

Ken Puls
01-15-2007, 12:04 AM
Actually...

Based on a quick Google search for "MouseOver VB", I found some code that will change the colour and font of the label1 as you move over/off it. You could probably tweak it to use an OnTime to display a message in another label and set it to invisible when you are done with it:

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Label1
.BackColor = vbGreen
.FontSize = 12
End With
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Label1
.BackColor = vbYellow
.FontSize = 8
End With
End Sub