Click to See Complete Forum and Search --> : Status Bar


Lev FatMan
April 19th, 2001, 09:53 AM
How Can I change the text in the status bar while the mouse is over a buttom or a text field?

FatMan

softweng
April 19th, 2001, 11:17 AM
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

Lev FatMan
April 23rd, 2001, 04:05 AM
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

Cimperiali
April 23rd, 2001, 04:16 AM
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.

shree
April 23rd, 2001, 06:38 AM
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

Cimperiali
April 23rd, 2001, 07:07 AM
Great.

Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.