Help : Progress Bar reaches end at 33%

Help : Progress Bar reaches end at 33%

Postby anserkk » Thu Sep 04, 2008 11:42 am

Frineds,

I am using PROGRESS object while Re-indexing my DBF files. Unfortunately The progress Bar display reaches the extreme right end, even when the percentage have reached only 33%.

The percentage is calculated as
(nCurrentNtxCount/TotalNoOf Indexes) * 100

I don't know where I have went wrong

Screen Snapshot

Image


My Code

Code: Select all  Expand view
*------------------------------------------------------------------*
Function ReIndex()
*------------------------------------------------------------------*
Local oDlg,nStyle,oProg

nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION ) // Removes the ? and x on the dialogue title
DEFINE DIALOG oDlg TITLE "Reindex Data Files" STYLE nStyle SIZE 600,300 PIXEL ;

@01,01 PROGRESS oProg POSITION 0 SIZE 250, 8
@03,01 BUTTON oBtn  PROMPT "Reindex" SIZE 40,12 ACTION  {oProg:SetStep( 1 ) , oProg:SetRange( 1, 100 ), DoIndexing(oDlg,oProg) }   
@03,10 BUTTON oBtn2 PROMPT "Close"    SIZE 40,12 ACTION  { CloseDbf("All"), oDlg:End() }   

ACTIVATE DIALOG oDlg CENTERED


Close Data   
Return .T.

*------------------------------------------------------------------*
Function DoIndexing(oDlg,oProg)  // called Sam.prg
*------------------------------------------------------------------*
Local nNtxNo,n

Use DBFS
count to nNtxNo for !empty(NTXNAME)

n:=0
Sele DBFS
Go top
Do while !eof()
   if !empty(ntxkey)
      sele c
      use
      if  ! Netuse((MastPath+alltrim(dbfs->DBFNAME)),EXCLUS_OPEN,USR_WRK_AREA,5)
         *loop
      endi
      @04,01 say "DBF "+dbfs->DBFNAME+" Records : "+str(reccount(),6)      
      @05,01 say padc("Indexing on "+alltrim(dbfs->NTXKEY)+' to '+alltrim(dbfs->NTXNAME)+'.NTX',78)
      inde on &(alltrim(dbfs->NTXKEY)) to &(Mastpath+alltrim(dbfs->NTXNAME))
      n++
      nPercent := VAL( STR(( n / nNtxNo ) * 100, 3, 0 ))
*      nPercent := ( n / nNtxNo ) * 100
      MsgInfo(str(nPercent)+"%")
      oProg:StepIt()
      oProg:nPosition += nPercent

   Endif   
   Sele dbfs
   skip
Enddo
Close Data
oDlg:End()
Return .T.


Regards

Anser
User avatar
anserkk
 
Posts: 1329
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Help : Progress Bar reaches end at 33%

Postby Patrick Mast » Thu Sep 04, 2008 12:09 pm

Hello,

I have also been strugling with TProgress for a few days now and I have gone back to the "old" meter class. I could not get TProgress to work properly. The Setrange() or Set() did not work ok. The bar was not set to the right position. I could not figure out how to work with TProgess.

Maybe Antonio can help us :)

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby anserkk » Thu Sep 04, 2008 5:54 pm

Any other alternative way to accomplish the task.?
User avatar
anserkk
 
Posts: 1329
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Antonio Linares » Thu Sep 04, 2008 6:57 pm

ProgressBars really puzzle me when used with themes :?

See this example and check how they get filled but finally get empty:

test.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oProg1, oProg2
   
   DEFINE DIALOG oDlg TITLE "Progress Bars"
   
   @ 1, 1 PROGRESS oProg1 SIZE 80, 12

   @ 1, 20 PROGRESS oProg2 SIZE 12, 50 VERTICAL
   
   @ 3,  9 BUTTON "Ok" ACTION oDlg:End()
   
   oDlg:bStart = { || Increase( oProg1, oProg2 ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ) )
   
return nil   

function Increase( oProg1, oProg2 )

   local n

   oProg1:SetPos( 0 )
   oProg2:SetPos( 0 )   
   
   for n = 1 to 100
      oProg1:StepIt()
      oProg2:StepIt()
      Sleep( 50 )
      SysRefresh()
   next
   
return nil       

I really would like to know why they get empty. Any suggestions :?:
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Thu Sep 04, 2008 7:17 pm

It looks like the nPercent you are calculating is the percent of the total number of indexes. Also you have defined the range as 0-100. So, try this--take out the first two lines and add the last line.

// oProg:StepIt()
// oProg:nPosition += nPercent
oProg:setPos( nPercent )

Regards,
James
Last edited by James Bott on Thu Sep 04, 2008 7:28 pm, edited 1 time in total.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Thu Sep 04, 2008 7:24 pm

Antonio,

They work fine under XP with the blue theme (I forget the theme name).
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Sep 04, 2008 7:36 pm

James,

Do you mean the "classic" theme ? (no themes). With no themes they work fine.

I got them working fine, but see the code. I can't see its logic :?

test.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oProg1, oProg2
   
   DEFINE DIALOG oDlg TITLE "Progress Bars"
   
   @ 1, 1 PROGRESS oProg1 SIZE 80, 12

   @ 1, 20 PROGRESS oProg2 SIZE 12, 50 VERTICAL
   
   @ 3,  9 BUTTON "Ok" ACTION oDlg:End()
   
   oDlg:bStart = { || Increase( oProg1, oProg2 ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ) )
   
return nil  

function Increase( oProg1, oProg2 )

   local n

   for n = 1 to 111
      // oProg1:StepIt()
      // oProg2:StepIt()
      oProg1:SetPos( n )
      oProg2:SetPos( n )
      Sleep( 50 )
      SysRefresh()
   next
   
return nil      
 

Here you have the EXE to test it:
http://rapidshare.com/files/142641253/progres1.zip.html

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Thu Sep 04, 2008 7:49 pm

Antonio,

>Do you mean the "classic" theme ? (no themes). With no themes they work fine.

No, I mean the "Windows XP" theme that is blue.

I agree, your latest code doesn't seem logical.

Please describe (when using the previous code) when the progress bar gets blank--at the end?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Thu Sep 04, 2008 7:52 pm

Antonio,

Your latest code works fine for me when using 111 or 100.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Sep 04, 2008 8:03 pm

James,

> Please describe (when using the previous code) when the progress bar gets blank--at the end?

Yes, on the final step (from 99 to 100) it gets empty. Really strange, as the right way to do it is to use the StepIt() method.

And it only fails in Vista with themes. Without themes is ok.

At least we have a workaround. Now we need other testers feedback.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Thu Sep 04, 2008 8:22 pm

Antonio,

>Yes, on the final step (from 99 to 100) it gets empty. Really strange, as the right way to do it is to use the StepIt() method.

Hmm, maybe if you do n = 0 to 99 instead? Or, set the range from 1 to 100 instead of 0 to 100?

Sorry, I can't test it here.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Sep 04, 2008 8:29 pm

James,

Could you test it with other XP themes ? thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Sep 04, 2008 8:32 pm

BTW, these are the docs for ProgressBars:

http://msdn.microsoft.com/en-us/library/bb760818(VS.85).aspx

We have done lots of tests, but we may be missing something.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Thu Sep 04, 2008 9:47 pm

Antonio,

The blue theme, silver theme, and classic (no theme) all work find under XP Pro.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Thu Sep 04, 2008 9:56 pm

Antonio,

I also tested about a half dozen different Window Blinds themes and all the progress bars work fine. Curiously, though, only the horizontal bars use the theme graphic--the vertical ones all use the classic segmented graphic. I think this must be a Window Blinds theme bug.

But, they all do work.

Window Blinds
http://www.stardock.com/products/windowblinds/

The problem seems to be limited to Vista.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests