CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Status Bar

  1. #1
    Join Date
    Feb 2001
    Location
    Israel
    Posts
    94

    Status Bar

    How Can I change the text in the status bar while the mouse is over a buttom or a text field?

    FatMan


  2. #2
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Re: Status Bar

    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
    Kris
    Software Engineer
    Phoenix, AZ USA

  3. #3
    Join Date
    Feb 2001
    Location
    Israel
    Posts
    94

    Re: Status Bar

    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


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Status Bar

    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.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Status Bar

    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





  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Status Bar

    Great.

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured