Results 1 to 10 of 10

Thread: Can I add a button to my status bar?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    7

    Can I add a button to my status bar?

    A while back, I found some code to add a progress bar to a status bar (I wanted it to look similar to the IE browser status bar). This progress bar (actually a custom StatusBarPanel) in the status bar was going to be my way of allowing the user to track how far along in a 'process' the app was. Now, I'd like to add a button (for cancelling) to the right of that progress bar.

    If someone could at least give me an idea or example of how to generally add a command button to the status bar, I'm sure I can figure out how to make it fit in with my customized status bar.

    Any help is much appreciated!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This should give you a start .
    VB Code:
    1. Dim gx As Graphics = Me.StatusBar1.CreateGraphics
    2.  
    3. ControlPaint.DrawButton(gx, New Rectangle(0, 0, 60, 30), ButtonState.Flat)

  3. #3
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Interesting, I never thought about a button in a status bar for a GUI. Guess I haven't noticed the IE browser status bar that you mention (I've noticed the status bar of course, just no buttons).

    How about a screen shot to take a look?

    TIA,
    Mike

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If some C# code doesn't scare you , then go to codeproject.com . loads of beautiful controls .

  5. #5
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Hmmm... cool stuff, I'm sure, giving it a quick look. Very cool programming anyway.

    Guess I'm still thinking "how would I use a button on a status bar" in my app. Interactive stuff and status stuff mixed together just doesn't make sense to me. Of course it may open up a nice GUI experience. That's why I want to see a screen shot of a deployed application.

    Regards,
    Mike

  6. #6
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    You can just create a regular button, and use the parent property.

    MyButton.Parent=MyStatusBar
    Then set the button location and size to match the panel, and you're set.

    Of course, if your app allows the user to resize, then you have to relocate the button to the new position on a sizechanged event.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  7. #7
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Why not shorten the status bar and put the button on the side instead?

    The status bar is named that for a reason, I don't think it was really ment to have buttons added to it.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    7
    Hey, all! Didn't mean to post and run away... I just had a busy weekend.

    Anyway, when I mentioned the IE bar I was refering to a status bar with progress bar, not necessarily the buttons. I've been asked why I would want a button on my status bar...

    Well, my company is having me re-write a HUGE app in .NET. The problem with it now is that it is so process-intensive that the user can do very little inside the app while one of these processes is running (some of these processes take hours). So, instead of forcing the user to look at a modal form with a progress bar (essentially locking them out of all other app functionality), I have decided to take advantage of threading and eliminate as many unnecessary forms as possible. I want it nice and concise. When one of these lengthy process is started, I want to thread the process thereby returning GUI control to the user for other app functions. The progress for that process can be tracked in the progress bar in the status bar (like IE) and all forms except the main form are closed. So what is the button for? CANCEL... I need to provide a simple way to abort the process if the user so desires. I've seen a status bar that looks exactly like this in various apps. The button is only visible to the right of the progress bar when the process is running.

    Hope that makes for sense.

    Thanks to all for the help. This should get me started. For some reason it just seem too easy. I'm trying to avoid always doing a relocate any time the form size changes, so I'll likely try Pirate's method first. I've also seen references to doing a StatusBar1.Controls.Add and specifying a button.

    Thanks again. I'll keep you posted.

  9. #9
    New Member
    Join Date
    Jan 2004
    Posts
    2
    I ran into a similar problem while trying to make a MDI web browser. I wanted a tabbed interface, kinda like Opera.

    All you really have to do is use the status bar itself!

    Use the Panels collection in the status bar. Each panel has 3 properties you're interested in, Borderstyle, Icon, and text.

    Border style determines the type of button it is, whether it's raised or inset. In my web browser, I used this as which window was active (active was inset, all others raised).

    Icon, is the icon. Of course.
    Text, is the text.
    Using this, you can emulate IE's status bar

    Just watch for the Status Bar's PanelClick event, then use "e.StatusBarPanel" as the panel. Apparantly in .NET, they removed the tag property, so you'll have to find some mechanism of tagging each button dynamically... perhaps a collection?

  10. #10
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by RoxSox
    I ran into a similar problem while trying to make a MDI web browser. I wanted a tabbed interface, kinda like Opera.
    I hate to be an ass, but just use Opera and don't try emulating it with IE's monkey-**** rendering engine in a .NET environment.

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