Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Need help with progress bar algorithm
  
User name:
Password:
Reply:
 

UserPost
HyperLamer
Posts: 2779/8210
Thanks, worked great! (Well it didn't at first, but then I realized I had it set to percentage. And yes, before you ask, I did have it on Value when testing the other formula. )

Now, how do I add a bitmap resource to an OCX control? (I tried going to Add File and selecting it, but it says it can't be added. ) I imagine my users wouldn't want to have to have these bitmaps packaged with their app.
labmaster
Posts: 10/43
Instead of Round(nValue / ((nMax - nMin) / NumDots)) try Round( NumDots * nValue/(nMax-nMin)). I don't really see why both of them shouldn't work though, since even though ((nMax-nMin)/NumDots) is < 1, dividing nValue by that should give a number larger than nValue.

HyperLamer
Posts: 2754/8210
I'm making a simple progress bar control, where you give it a minimum, maximum and value, and it draws these little dots (small images) that represent the value. There are 4 modes:
1) Value given is out of max, starting at min. Eg: max=20, min=5, value=10 means 5/15 (subtract min from both).
2) Value is a percentage of max.
3) Value is the number of dots to draw.
4) Draw a user-specified string determining the colours of each dot. (Eg: 'rrbby' draws 2 red, 2 blue, one yellow.)

Mode 4 works (and it has to, since the other 3 modes really just generate strings for it), and mode 3 as well (easy). 1 and 2 have a problem, it's kinda hard to explain. The control calculates the number of dots required to cover its width (or height, in vertical mode). It then calculates how many dots to draw with the 'full' type, and all the rest are drawn with the 'empty' type. (The user chooses which type of dots to use for each.) Now these algorithms work, except for one condition: if (max - min) is less than the number of dots needed to fill the bar, they come out to zero full dots. (I can see why, since the number divided by the number of dots is less than one, just dunno how to fix it.) The algorithms are as follows:

For mode 1:
Round(nValue / ((nMax - nMin) / NumDots))

For mode 2, same thing, but replace '(nMax - nMin)' with 100.

This is VB6 so Round() rounds up or down as necessary, and / refers to real-number division (5 / 2 = 2.5, not 2). So can anyone figure this out?

Also, unrelated: How complicated is the BitTorrent protocol? It'd be a neat project to try out if it's not too difficult.

[edit] I found the protocol specs, sounds doable. I don't get what lists and dictionaries are for, though. I imagine the dictionaries are for text compression? What do lists do and how are they to be stored? (Like, multiple entries or one in some special format?)
Acmlm's Board - I2 Archive - Programming - Need help with progress bar algorithm


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.004 seconds.