Results 1 to 15 of 15

Thread: [2005] Smooth ProgressBar?

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    [2005] Smooth ProgressBar?

    Hello everyone,

    I am using the ProgressBar control, but I need it to have a continuous scale (like when you set Scrolling to 1 (= ccScrollingSmooth) in VB6). The blocks it uses now are not fine enough.

    Setting Style to 'Continuous' won't work.

    I use Windows XP Media Center Edition 2002 SP2.

    Thanks.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Smooth ProgressBar?

    You cannot have a continous bar with visual styles enabled for the control. You might want to use a third-party progress bar. Have a look at the ElementsEx link in my signature.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Re: [2005] Smooth ProgressBar?

    That looks nice, I'll have a look at those.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Smooth ProgressBar?

    you can do 1 of 2 things.

    1) Turn of visual styles for your project, and you will be able to get a smooth scrolling on the continuous setting.. (the blocks are a result of visual styles) However turning off visual styles will be for the entire project, not just the one control..

    2) Add the mscomctl.ocx to your toolbar, and then add the VB6 version of the progress bar to your form. VS should hook up the required references into your project. This progress bar won't use visual styles.

    An even 3rd possible option, is to use some 3rd party DLL like the skybound visual styles one (which is free and works quite well). This component gives you the per control ability to enable/disable visual styles...

  5. #5

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Re: [2005] Smooth ProgressBar?

    In the meanwhile I found a half-solution.

    Disable the option: "Enable XP visual styles" in the project's options.
    This disables the 'skinning' of applications and makes your controls look like Win 98 controls.

    Then enter in the MyBase.Load event code: Application.EnableVisualStyles()
    This does change buttons and menu's back to their XP-layout, but the progressbar stays in it's Win 98-style, which DOES support smooth scrolling.

    I also checked out the ElementsEX control, but for my application it has little extra to offer than the solution I use now and I would really like to stay with Window's default controls.

    What I would really like is a smooth XP-style scrollbar, which must be possible to achieve. Because, for example, FireFox uses it in it's downloads screen (see the attachment).
    Attached Images Attached Images  
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  6. #6
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Smooth ProgressBar?

    Quote Originally Posted by arsmakman
    In the meanwhile I found a half-solution.

    Disable the option: "Enable XP visual styles" in the project's options.
    This disables the 'skinning' of applications and makes your controls look like Win 98 controls.

    Then enter in the MyBase.Load event code: Application.EnableVisualStyles()
    This does change buttons and menu's back to their XP-layout, but the progressbar stays in it's Win 98-style, which DOES support smooth scrolling.

    I also checked out the ElementsEX control, but for my application it has little extra to offer than the solution I use now and I would really like to stay with Window's default controls.

    What I would really like is a smooth XP-style scrollbar, which must be possible to achieve. Because, for example, FireFox uses it in it's downloads screen (see the attachment).
    This scroll bar visual style comes with the "Royal" theme by Microsoft
    EDIT: so if you try it on a computer that works on XP Pro with no Royal theme installed, it won't look the same
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Smooth ProgressBar?

    Quote Originally Posted by ComputerJy
    This scroll bar visual style comes with the "Royal" theme by Microsoft
    EDIT: so if you try it on a computer that works on XP Pro with no Royal theme installed, it won't look the same
    yeah but you can't really rely on a specific theme (especially one limited to a single OS)

    I am sure it would be pretty simple to build the firefox style one.. progress bars are probably one of the easier controls to make, as they are just for display, and don't require any user interaction

  8. #8
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Smooth ProgressBar?

    Quote Originally Posted by kleinma
    yeah but you can't really rely on a specific theme (especially one limited to a single OS)

    I am sure it would be pretty simple to build the firefox style one.. progress bars are probably one of the easier controls to make, as they are just for display, and don't require any user interaction
    1- That's exactly what I said
    2- it's not a firefox style, the style comes with the "Royal" style made by Microsoft not Mozilla
    Attached Images Attached Images  
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Smooth ProgressBar?

    Quote Originally Posted by ComputerJy
    1- That's exactly what I said
    2- it's not a firefox style, the style comes with the "Royal" style made by Microsoft not Mozilla
    sorry, I didn't know you were referring to the firefox progress bar. I thought you were offering using that theme as a solution

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Smooth ProgressBar?

    I guess the "best" answer is to inhertit the ProgressBar control and handle the drawing yourself. You might like to check out the XPCC link in my signature. That guy seems to know a lot about visual styles and drawing controls. He has articles on the site on the subject, plus you can check out his source code for the XP Common Controls library.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Smooth ProgressBar?

    John,
    I was under the impression that a control needs to allow owner drawing via the ownerdrawn property to allow custom painting of the control... (like listbox, listview, etc...)

    I never could get an OnPaint sub to fire in an inherited class unless I was able to set its OwnerDrawn property..

    do you know a trick to get that to work?

  12. #12
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Smooth ProgressBar?

    Quote Originally Posted by arsmakman
    Hello everyone,

    I am using the ProgressBar control, but I need it to have a continuous scale (like when you set Scrolling to 1 (= ccScrollingSmooth) in VB6). The blocks it uses now are not fine enough.

    Setting Style to 'Continuous' won't work.

    I use Windows XP Media Center Edition 2002 SP2.

    Thanks.
    Hi,

    Here's a link where you can find some smooth progressbars;

    http://www.codeproject.com/vb/net/SPB.asp

    http://www.codeproject.com/vb/net/SmoothProgressBar.asp

    http://www.codeproject.com/vb/net/Pe...rogressBar.asp

    Try it,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Smooth ProgressBar?

    Quote Originally Posted by kleinma
    do you know a trick to get that to work?
    I think you'd have to inherit the class and do it from the inside.

    That first link of sparrow's looks good. It is more visually appealling than the ones that look like the Windows Classic theme so it should fit in with XP themes better. If you use it you should make sure that you use colours from the SystemColors class so that they change with the current theme, rather than specifying absolute colours which may clash with some themes.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    297

    Re: [2005] Smooth ProgressBar?

    I agree, like the codeproject and other examples out there, just roll-your-own. Progress bars are pretty easy to draw, and you can learn about creating custom controls, adding properties, double buffering, invalidating only the area that has changed, drawing in the paint event (or overriding it), fancy brushes (LinearGradientBrush)...

    VB Code:
    1. '2005
    2. Public Class Form1
    3.  
    4.     Dim pb As New ProgressBra
    5.     Dim WithEvents t As New Timer
    6.  
    7.     Sub New()
    8.         InitializeComponent()
    9.         Me.Controls.Add(pb)
    10.         pb.Dock = DockStyle.Top
    11.         pb.Minimum = 0
    12.         pb.Maximum = 1000
    13.         t.Interval = 1
    14.         t.Start()
    15.     End Sub
    16.  
    17.     Private Sub t_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Tick
    18.         pb.Value += 1
    19.         ' Only invalidate a small rectangle at the end of the progress bar, as that is all that changed
    20.         Dim endOfBar As Single = (pb.Value / pb.Maximum) * pb.ClientSize.Width
    21.         pb.Invalidate(New Rectangle(endOfBar - 1, 0, 2, pb.ClientSize.Height))
    22.     End Sub
    23. End Class
    24.  
    25. Public Class ProgressBra
    26.     Inherits ProgressBar
    27.  
    28.     Sub New()
    29.         Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer, True)
    30.         Me.UpdateStyles()
    31.     End Sub
    32.  
    33.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    34.         e.Graphics.FillRectangle(Brushes.Black, New Rectangle(0, 0, (Me.Value / Me.Maximum) * Me.ClientSize.Width, Me.ClientSize.Height))
    35.     End Sub
    36. End Class

  15. #15
    Lively Member bmilano's Avatar
    Join Date
    Jan 2005
    Location
    Broad Run, VA
    Posts
    126

    Re: [2005] Smooth ProgressBar?

    I use Global Majic's Linear Gauge in my app, and it does the smooth progress bars that you are looking for. It also has the capability of an overlaying caption so you could show the percentage number overlaid on the progress bar as the progress bar is moving.

    Smooth progress bars weren't the reason I bought it, but it was a nice side benefit. I was looking for a two-headed slider and Linear Gauge was the only one I could find.

    The software can be found on componentsource.com. There is an ActiveX version and a .NET version.
    If you like my posts, please rate them so I can be somebody!

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