Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Kulwant Singh
  Where is Kulwant Singh?
 Shimla
 India
 Kulwant Singh
 Tags
Subject: RE: Fractions of Pixels
Thread ID: 112443 Message ID: 112445 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: Visual Basic
Date: Wednesday, November 08, 2006 4:59:15 PM         
   


> Hello Experts,
>
> I have a another PROBLEM. I need your help.
>
> I created a progress bar with 2 shapes on a form. The outer shape1 has a width of 400. The Inner shape2 starts with 0. There are 239 records in a table. I calculate the incremental value with this formula :
> mDONE = 400 / RECCOUNT() which in this case works out to 400/239 = 1.6736.
>
> then i use:
> SELE mFILE
> GO TOP
> DO WHILE NOT EOF()
> thisform.shape2.width = thisform.shape2.width + mDONE
> SKIP
> ENDDO
>
> My Problem.
> When I run the form the inner shape2 ends up halfway within the outer shape1. It is not covering the full length of 400. With (1.6736 * 239) it should end up at 400.
>
> If i use CEILING(mDONE) the length will exceed 400 AND overshoot the outer shape1.
>
>
> With FPW the above formula worked because the unit of calculation was 'columns'. How do i make it work with pixels in VFP.
>
> Another very important question:- Where should this code reside? I have put it in the 'init' proceedure of the form
>
>
> Thanks!
> kulwant


Kulwant,

You need to calculate the progress in terms of percentage:
lnRecCount = RECCOUNT([MyTable])
lnCounter = 0
SCAN
   lnCounter = lncounter+1
   lnPctProg = INT((lnCounter/lnRecCount)*100)
   IF MOD(lnPctProg,5) = 0
      thisform.shape2.width = lnPctProg * 4 && 400 MaxWidth/100%
      ThisForm.Shape2.Refresh()
   ENDIF 
   && do what ever it is that you need to do
ENDSCAN


Note the SCAN/ENDSCAN - this is faster than DO WHILE. Note also that updating at every loop will definately slow down the works. Twenty refreshes should show movement but at the same time, should not slow down the works. Do some tests - even a WAIT WINDOW NOWAIT every loop takes a fair amount of time.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Fractions of Pixels Posted by kulwant singh @ 11/8/2006 4:37:25 PM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/8/2006 4:59:15 PM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/9/2006 7:12:24 AM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/9/2006 8:24:06 AM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/10/2006 7:45:48 AM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/10/2006 11:59:55 AM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/10/2006 10:23:33 PM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/11/2006 2:03:23 AM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/12/2006 3:27:30 AM
RE: Fractions of Pixels Posted by Yuri Rubinov @ 11/8/2006 5:12:09 PM
RE: Fractions of Pixels Posted by Carlos Alloatti @ 11/8/2006 8:32:52 PM