FF_ProgressBar

Started by Shawn Anderson, October 21, 2009, 08:49:26 PM

Previous topic - Next topic

Shawn Anderson

I'm trying get a progress bar to work.
I set the range for it using

FF_ProgressBar_SetRange (ByVal HWND_MAINFORM_PROGRESSBAR1, 1, recs)

(recs is a number around 18000)

then in my loop, I'm trying to increment like this

' counter starts at 1 and increments
Incr counter             
FF_ProgressBar_IncPos (ByVal HWND_MAINFORM_PROGRESSBAR1, counter)


but the progress bar goes to 100% right away

TechSupport

That did seem strange when I read your post, however, I checked out the WinAPI docs for the ProgressBar and it appears that for Progress Bars that the maximum value is 100. Check out this post: http://msdn.microsoft.com/en-us/library/bb760848(VS.85).aspx

The easiest way to accomplish what you need is to set the Progress bar for 1 Min, 100 Max and use the percentage completed to update the Progress Bar.


   Local MaxRecs As Long
   Local counter As Long
   Local y       As Long
   
   MaxRecs = 18000
   
   ' counter starts at 1 and increments
   For y = 1 To 18000
      Incr counter             
      FF_ProgressBar_SetPosition HWND_MAINFORM_PROGRESSBAR1, (counter/MaxRecs) * 100
      FF_Control_SetText HWND_MAINFORM, Str$((counter/MaxRecs) * 100)
      FF_DoEvents
   Next



Pat Dooley

But this seems to work fine. A value of 9000 in the textbox moves the progress bar halfway as expected.
Local pval As Long
Local tmp As String
'tmp<=max value
tmp=FF_TextBox_GetText (HWND_FORM1_TEXT1)
pval=Val(tmp)
'Max value set to 18000 in progress bar properties
FF_ProgressBar_SetPosition (HWND_FORM1_PROGRESSBAR1, pval)


Pat

Pat Dooley

One more thing Shawn. When you increment the progress bar by the the counter value, you reach the max value very quickly. You should increment the progress by a value of 1 not the value of the counter. First you increment by 1, the 2, then 3, etc.  Your code would exceed the value of 18000 after the 189th run through the loop.  I think it is called the sum of a series.
(n(n+1))/2 = 17955 where n=189.

Pat

Shawn Anderson

this is working for me:


FF_ProgressBar_SetRange (ByVal HWND_MAINFORM_PROGRESSBAR1, 1, 100)     
FF_ProgressBar_SetStep (ByVal HWND_MAINFORM_PROGRESSBAR1, 1)


then in my loop


        ' progCount is a long
        ' counter is incremented, recs is total number of records
        progCount=(counter/recs)*100
        FF_ProgressBar_SetPosition (ByVal HWND_MAINFORM_PROGRESSBAR1,progCount)   


thanks everyone