Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Need help with progress bar algorithm | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 2754/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
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?) (edited by HyperHacker on 01-01-05 01:55 AM) (edited by HyperHacker on 01-01-05 03:21 AM) |
|||
labmaster Blue Octorok Level: 12 Posts: 10/43 EXP: 6135 For next: 1786 Since: 07-17-04 From: New Zealand! Since last post: 10 days Last activity: 2 min. |
| ||
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 <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 2779/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
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. (edited by HyperHacker on 01-02-05 11:03 PM) |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Need help with progress bar algorithm | | | |