Results 1 to 13 of 13

Thread: Some kind of process bar

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Some kind of process bar

    Hello, is there a way to have a process bar in your application like the one you see when Windows XP starts up? It's not a progressbar, but a bar where several small squares move from left to right in the bar, telling you that a process is currently running.

    Thanks.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Some kind of process bar

    Someone posted an animated GIF file that he made that was pretty good. I saw it this morning, so it should still be on the first page, as there haven't been too many threads since I left.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Some kind of process bar

    I found it. Thank you.

  4. #4
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: Some kind of process bar

    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Some kind of process bar

    Thanks wiz126, but that's a progressbar. I'm executing command-line tools and there is no way I can determine how far the progress of a command-line tool is, so I can't update the progressbar while the tools are running.

    Actually I was looking for something more like this:


  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Some kind of process bar

    I've made a custom bar like the one on the picture above. It are several pictures that get changed on a timer interval, so it looks like it's one bar with moving squares.

    It works great with the code below, but that means I need to have all the pictures stored somewhere on the computer, but I'd like to have the pictures inside the application.

    Is it not possible to put several Image controls on top of each other and then use a timer to show them after each other? Or is there maybe another way of doing this?

    This is the code I'm using now.

    VB Code:
    1. Private Sub Form_Load()
    2.     'Set up a list of pictures to show
    3.     PicArray(1) = "C:\1.bmp"
    4.     PicArray(2) = "C:\2.bmp"
    5.     PicArray(3) = "C:\3.bmp"
    6.     PicArray(4) = "C:\4.bmp"
    7.     PicArray(5) = "C:\5.bmp"
    8.     PicArray(6) = "C:\6.bmp"
    9.     PicArray(7) = "C:\7.bmp"
    10.     PicArray(8) = "C:\8.bmp"
    11.     PicArray(9) = "C:\9.bmp"
    12.     PicArray(10) = "C:\10.bmp"
    13.    
    14.     'Set a variable to count the pictures done (or the slide number, in the slide show)
    15.     SlideCount = 1
    16.  
    17.     'Set up the timer
    18.     Timer1.Enabled = True
    19.     Timer1.Interval = 100
    20.  
    21. End Sub
    22.  
    23. Private Sub Timer1_Timer()
    24.     'This will happen every 1000 millisecond
    25.     SlideCount = SlideCount + 1
    26.     If SlideCount > 10 Then SlideCount = 1
    27.     Set Image1.Picture = LoadPicture(PicArray(SlideCount))
    28. End Sub

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Some kind of process bar

    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Some kind of process bar

    Here, I just wrote this:
    Just put on the form a timer named tmrProcess, and a picturebox named picProcess, then paste this code in the form.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const PI As Double = 3.14159265358979
    4.  
    5. Private Sub Form_Load()
    6.     picProcess.ForeColor = vbBlue
    7.     picProcess.AutoRedraw = True
    8.     picProcess.BorderStyle = 0
    9.     picProcess.Appearance = 0
    10.     picProcess.BackColor = Me.BackColor
    11.    
    12.     tmrProcess.Interval = 10
    13.     tmrProcess.Enabled = True
    14. End Sub
    15.  
    16. Private Sub picProcess_Resize()
    17.     picProcess.Cls
    18. End Sub
    19.  
    20. Private Sub tmrProcess_Timer()
    21.     Static PrevPos As Single, Direction As Boolean
    22.    
    23.     Dim BHeight As Single, Pos As Single, K As Single
    24.     Dim BarLen As Single
    25.     BarLen = picProcess.ScaleWidth * 0.2
    26.     BHeight = picProcess.ScaleHeight - 15
    27.    
    28.     picProcess.Circle (BHeight / 2, BHeight / 2), BHeight / 2, 0, PI * 0.5, PI * 1.5
    29.     picProcess.Circle (picProcess.ScaleWidth - BHeight / 2 - 15, BHeight / 2), BHeight / 2, 0, PI * 1.5, PI * 0.5
    30.     picProcess.Line (BHeight / 2, 0)-(picProcess.ScaleWidth - BHeight / 2, 0), 0
    31.     picProcess.Line (BHeight / 2 - 15, BHeight)-(picProcess.ScaleWidth - BHeight / 2, BHeight), 0
    32.    
    33.     If PrevPos = 0 Then PrevPos = BHeight / 2
    34.    
    35.     If Not Direction Then
    36.         Pos = PrevPos + picProcess.ScaleWidth * 0.015
    37.         If Pos + BarLen > picProcess.ScaleWidth - BHeight / 2 - 15 Then Direction = True
    38.     Else
    39.         Pos = PrevPos - picProcess.ScaleWidth * 0.015
    40.         If Pos < BHeight / 2 Then Direction = False
    41.     End If
    42.    
    43.     picProcess.Line (PrevPos, 30)-(PrevPos + BarLen, BHeight - 30), picProcess.BackColor, BF
    44.     picProcess.Line (Pos, 30)-(Pos + BarLen, BHeight - 30), , BF
    45.    
    46.     For K = Pos To Pos + BarLen Step picProcess.ScaleWidth * 0.05
    47.         picProcess.Line (K, 30)-(K, BHeight - 15), picProcess.BackColor
    48.     Next K
    49.    
    50.     PrevPos = Pos
    51. End Sub

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Some kind of process bar

    Quote Originally Posted by CVMichael
    Here, I just wrote this:
    Just put on the form a timer named tmrProcess, and a picturebox named picProcess, then paste this code in the form.
    That looks great. Thank you.

    Now I need to use both bars

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Some kind of process bar

    What does that even mean?

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Some kind of process bar

    Thanks, Mc Brain. That looks very nice. I'll use that one. All the BMP pictures that I have now, make the size of the application 3 times bigger.

  12. #12
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Some kind of process bar

    Glad I could help. I might look for a neweer version of it. I'm not sure if I corrected or improved anything... but I most probably have done it.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Some kind of process bar

    I'm not sure what you're talking about, dglienna.

    EDIT: Is it about your post?
    I did use the bar you pointed me to, but that bar (gif) is really small. When I got other solutions from Mc Brain and CVMichael, which are better for my application, I started to use them instead. I'm not trying to be rude or ungrateful, but if I get several solutions, then I use the best ones.
    Last edited by Chris001; Nov 25th, 2005 at 09:02 PM.

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