How Can I change the text in the status bar while the mouse is over a buttom or a text field?
FatMan
Printable View
How Can I change the text in the status bar while the mouse is over a buttom or a text field?
FatMan
Here is some sample code. I am using a StatusBar with 3 panels called sbrSystemStatus:
option Explicit
private Sub Command1_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
'//Update Status Bar
sbrSystemStatus.Panels(1).Text = "This is Panel 1"
sbrSystemStatus.Panels(2).Text = "This is Panel 2"
sbrSystemStatus.Panels(3).Text = "This is Panel 3"
End Sub
private Sub Text1_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
'//Update Status Bar
sbrSystemStatus.Panels(1).Text = "Change Text for Panel 1"
sbrSystemStatus.Panels(2).Text = "Change Text for Panel 2"
sbrSystemStatus.Panels(3).Text = "Change Text for Panel 3"
End Sub
Kris
Software Engineer
Phoenix,AZ
The problem with that is that the text is changed and stays that way. I want it to change back as soon as I am not over the mouse.
FatMan
So, put your default text in a variable.
On mouse move over the button, change it.
On mouse move over the form or any else control, restore the default.
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
A better method than to write the same code on the form and all the neighboring controls is to detect when the mouse actually gets out of the control. Here's a code that demonstrates this. It is applicable to all controls that have a hWnd (most controls except the lightweight ones - the imagebox and the label have it)
private Declare Function ReleaseCapture Lib "user32" () as Long
private Declare Function SetCapture Lib "user32" (byval hwnd as Long) as Long
private Sub Picture1_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
SetCapture (Picture1.hwnd)
If X < 0 Or Y < 0 Or X > Picture1.ScaleWidth Or Y > Picture1.ScaleHeight then
MsgBox "The mouse got out"
ReleaseCapture
End If
End Sub
private Sub Command1_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
SetCapture (Command1.hwnd)
If X < 0 Or Y < 0 Or X > Command1.Width Or Y > Command1.Height then
MsgBox "The mouse got out"
ReleaseCapture
End If
End Sub
Great.
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.