Progress Bar

Discussion in 'Questions (Windows Mobile)' started by Caravelle, Sep 20, 2009.

  1. Caravelle

    Caravelle Active Member Licensed User

    I'm trying to implement a Progress Bar. I have added ControlsEx.dll, to my project, added a Progress Bar object (PBar), but my program grinds to a halt at the line where I declare PBar.New1 with this message:

    Code:
    Line number: 94
    PBar.New1
    Error description: Index was out of range.  Must be non-negative 
    and less than the size of the collection.  Parameter name: index.
    Huh? What index, what collection?

    Maybe this should have gone in the "confusing error messages" thread. I admit I've probably gone astray somewhere when adding the library/object, as it never seems to work the same way twice, but the Tools menu does show the Pbar object as present. When adding libraries/objects I invariably come across two or three error messages along the way and have to start again.

    Thanks

    Caravelle
     
  2. mjcoon

    mjcoon Well-Known Member Licensed User

    I think that the index and collection may refer to Basic4PPC's internal dictionary. And that when I've got similar messages it has been because I used the same name for a control, sub and/or variable. I think it's best to ensure uniqueness, perhaps by using, say, PBarObj for the names of objects. Their names do not appear as declarations in the code which makes it easier to re-use by accident.

    Mike.
     
  3. timsteeman

    timsteeman Member Licensed User

    How much help, do you want?

    Please see attached picture, for the help on this one.
     

    Attached Files:

    • pbar.JPG
      pbar.JPG
      File size:
      42.8 KB
      Views:
      104
  4. Ariel_Z

    Ariel_Z Active Member Licensed User

    As timsteeman showed, the method NEW1 takes 5 parameters (this is often a convention in Basic4ppc) being the form name to which to add it, left, top, width and height. When calling a method with a wrong number of parameters (or none at all...) this is the error message that's shown. Obviously this should be collected under the Confusing error messages thread. You might consider something like (note where I placed brackets):
    Code:
    pbar.New1("Form1"0100, Form1.Width, Form1.Height)
     
  5. Caravelle

    Caravelle Active Member Licensed User

    Hmmm. Typed too quickly there so the pop-up came and went in a flash - haven't come across a "New1" with parameters before (it's only been a week or two). I see if you do try to select from the pop-up, though, you still get ".New1" without any brackets or placemarker parameters.

    Those parameters sure make a diference! And if the error message had just said "parameters missing" that might have given me a clue.

    Many thanks

    Caravelle
    I learn by my mistakes - so I learn a lot in a short time.
     
  6. Caravelle

    Caravelle Active Member Licensed User

    My last reply crossed with Ariel_Z's.

    Code:
    pbar.New1("Form1"0100, Form1.Width, Form1.Height)
    I'm curious. Was there a reason to make the bar the size of the form?

    I just put in the numbers I'd already coded the hard way later in my program, Pbar.left=15 and so on. It lives under a pie-chart and when a button is pressed, the pie-chart disappears and the progress bar appears.

    It would be nice if the colours could be set! The bar looks rather dull after the red, yellow and lime green of the pie chart.

    The project I described when I first joined the Forum is coming along quite well. I have yet to work on the database aspects, but they are secondary.

    Thanks
     
  7. Ariel_Z

    Ariel_Z Active Member Licensed User

    No good reason. Just example.
     
  8. agraham

    agraham Expert Licensed User

    Unfortunately this is not possible on the device as the color properties are not made available in .NET. You could always draw your own!

    Code:
    Sub DrawBar(x, y, w, h, val)
       
    ' assume val range is 0 to 100
       xv = w * val/100 + x
       Form1.Line(x, y, xv, y+h, cRed, BF)
       Form1.Line(xv, y, x+w, y+h, cWhite, BF)   
    End Sub
     
  9. Caravelle

    Caravelle Active Member Licensed User

    Actually, I'm toying with the idea of something like an LED bar graph - equal-sized blocks of colour with a small gap between them. Placing coloured labels in line on a black panel would be one simple (well, simplish) solution, and change the colour of the labels as the total builds up. I don't need much more than 10% increments for a quick progress indication (my current progress bar increments in this manner). The iPAQ transfers jpgs from my camera CF card to my SD card at about 15 a minute so a batch of up to 4 Gigs' worth are going to take a while. I've set up a countdown timer showing the number of minutes left too. It's all overkill, but a good way of learning how things are done.

    Caravelle
     
  10. Ariel_Z

    Ariel_Z Active Member Licensed User

    Thought about you today - how is your project going?
     
  11. Caravelle

    Caravelle Active Member Licensed User

    Fine thanks. When the program starts it checks that the cards are inserted, and that the CF card is one from my camera (ie if there is a "DCIM\CANON100" folder) then when happy that the right cards are inserted, it shows a pie chart with labels showing how much space is used on the destination card, how much space will be used by the files to be added and how much space will be left after the transfer. A transfer button starts the transfer process off, and a cancel button backs out (for example if there is not enough room on the destination card). A progress bar and coundown timer then indicate progress of the transfer. I plan to add a "beep" when the transfer is finished.

    I shall have to do some experimenting to see what happens if the PDA battery runs down half-way through the transfer. And will an ongoing transfer prevent it from switching itself off when on battery? Normally I would expect to have it on external power, but this may not always be possible.

    I would also like (a) to be able to interrupt the transfer process if necessary and continue from the same point later and (b) for the transfer to run in a thread enabling me to use the PDA for other tasks if that is possible. I think it may be necessary to run it in a thread in order to enable a Pause or Break button click event to be detected. But I do not yet understand threading, I have been programming in Delphi for many years and have not succeeded in making a thread work yet! I shall check out the threads library and see if it makes any sense to me. There may be another mechanism for this, I just don't know (yet).

    I am thinking about the best way of dealing with the database work, playing around with the various options. Above all it has to be simple and quick and as automated as possible. There is no point if I miss taking the best photos because my hands are full playing with the PDA!

    Thanks for your interest.

    Caravelle
     
  12. taximania

    taximania Well-Known Member Licensed User

    Attached is a bar graph example. Any use to you ?
     

    Attached Files:

  13. Caravelle

    Caravelle Active Member Licensed User

    Thanks. That's very neat and I haven't come across the useful Control(). technique before - there are only so many things you can discover in a short period! I was thinking of using labels rather than images - they look the same if all you want is simple rectangles of colour and they don't need the jpgs stored on the device. My bar would be two colours only - showing what's done so far and still to go. It would be nice to make the segment which is currently being completed stand out, maybe flickering between the two colours, or slowly changing from one colour to the other in proportion to how close the particular segment is to completion. But that's just a cosmetic bit of fun (and would take an understanding of RGB values that I don't have yet).

    What I have now works, so I'll be getting the rest of the project working before tinkering with the bells and whistles.
    Thanks again.

    Caravelle
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice