message on mousemove

geno

Registered User.
Local time
Today, 05:49
Joined
Jun 19, 2000
Messages
243
I have a msgbox that shows on a mousemove. As of now you have to click OK to close the msgbox. Is there a way to have the msgbox close when the mouse is moved away from the text box?

Thanks
 
It doesn't sound like good use of vb tools to always pop a message box when your mouse hovers over a control. Why not use Control Tip Texts instead?
 
Perhaps you need to have a look at the ControlTip Text property available on the Other Tab of the text box when the form is in design view.
 
I clicked on your link but the page is no longer available. Do you have another way to get this information?
Thanks
 
You can do this but not with a message box. I use a Label to emulate the messagebox, and make the label Visible with the MouseMove event of the textbox, then make the label invisible using the form section's MouseMove event, such as Detail_MouseMove, when the mouse moves off of the control onto the form section.

Here’s part oF a short tutorial I wrote a while back on the use of the MouseMove event:
Another application for MouseMove would be to show a label with a help message as a replacement for Access’ rather anemic ControlTips. The label is created and positioned in an appropriate place on the form. Unlike ControlTips, all of the usual label formatting functions can be utilized. In the label’s Property Box, the Visible property is set to NO so that the label doesn’t appear until called by the MouseMove event. When the mouse cursor moves over a form object, the label appears, then disappears when the mouse rolls off of the object.

This pops up the Help message

Code:
Private Sub ClientName_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   lblClientNameHelp.Visible = True
End Sub
This causes the Help message to disappear when the mouse rolls off of the textbox
Code:
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   lblClientNameHelp.Visible = False
End Sub

As has been suggested, you could use the ControlTip property, but my experience, and apparently that of many others, from the number of posts I've seen on the subject, is that they are frequently problematic, sometimes working, sometimes not, and often slow to appear. Personally I never use them but use something like you're attempting.

(Sorry abut the broken link. The article is still there but the site is having problems this evening.)
 
That's true re the ControlTip property missinglinq. Especially if you hover quite quickly. The only problem with using the detail_mousemove event (as you mentioned) is that it will keep running for every mouse move, but it works. I think it would be more efficient for it to check against a variable instead, something like this:

Declare the variable in declarations section of form
Code:
Dim hideMe as Boolean

The detail section to check against boolean variable and hide if true
Code:
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If hideMe = True Then
        hideMe = False
        lblClientNameHelp.Visible = False
    End If
End Sub

The label that shows the help message to ensure that if the mouse hovers over it, it changes the visible property to false. (That's up to you how you want this behaviour because the detail section is only a container, the mouse move needs to be handled on label level)
Code:
Private Sub lblClientNameHelp_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    lblClientNameHelp.Visible = False
End Sub

Text box that will make the label visible (if it has text)
Code:
Private Sub txtBox1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Len(lblClientHelp.Caption & "") <> 0 Then
         hideMe = True
         lblClientNameHelp.Visible = True
    End If
End Sub

There shouldn't be any flicker:)

It would also be nice to set a border colour for the label too.

Hope this helps!
 

Users who are viewing this thread

Back
Top Bottom