Inserting a progress bar with xBrowse

Inserting a progress bar with xBrowse

Postby Rick Lipkin » Mon Aug 06, 2012 5:21 pm

To All

I have reviewed the sample xBrprogb.prg and am trying to adapt a progress bar to xBrowse. I can not seem to adapt the object code for the new column:

Code: Select all  Expand view


WITH OBJECT oBrw:Age
       :cHeader    := 'Percent'
       :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
       :nDataStrAlign := AL_RIGHT

END

 


I want to be able to add a new column 10 using the syntax

Code: Select all  Expand view

 ADD oCol TO oBrw AT 10  ...

 


Also .. I do not seem to understand the SetProgBar( 100, 104 ... What do these values represent ?

The progress bar will actually be the value between a "Start Date", "End Date" and the percentage complete by Date()

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Inserting a progress bar with xBrowse

Postby reinaldocrespo » Tue Aug 07, 2012 12:05 am

Hi Rick;

From the source file: METHOD SetProgBar( nProgTotal, nWidth, bClrProg )

Here is how to use it:

Code: Select all  Expand view

      :Progress:nTotal          := 0
      :Progress:lTotal          := .t.
      :Progress:SetProgBar( 100.00, 0.00, oBrw:bClrStd )
      :Progress:nDataStrAlign := AL_RIGHT
      :Progress:cEditPicture    := "999.99%"
 


To see the progress bar grow, change 2nd parameter up to 100. It is that simple.



Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Inserting a progress bar with xBrowse

Postby Rick Lipkin » Tue Aug 07, 2012 12:48 pm

Reinaldo

I have spent a good part of the day yesterday working on this ..

I just do not see how the method paints the progress bar and how it manipulates its values?? I am looking at incorporating this logic to create a percentage of completion for a project with a start date, projected end date with respect to today's date and then paint a progress bar in a column.

Rick Lipkin

Code: Select all  Expand view


ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Percent' RIGHT size 90


//------------------------
Static Func _CalcPercent( dStart, dEnd )

Local nPercent,nDiff,nElapsed

dStart   := TtoDate(dStart )
dEnd     := TtoDate( dEnd )
nPercent := 0

nDiff    := ( dEnd  - dStart )

If nDiff > 0
Else
   nPercent := 0
   Return( ltrim(str(nPercent))+" %" )
Endif

nElapsed := (Date() - dStart )
nPercent :=  nElapsed / nDiff
nPercent := round(nPercent * 100,0)

If nPercent > 100
   nPercent := 100
Endif

Return(ltrim(str(nPercent))+" %" )
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Inserting a progress bar with xBrowse

Postby ADutheil » Tue Aug 07, 2012 1:23 pm

You might try something like that:

Rick Lipkin wrote:
Code: Select all  Expand view


ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Percent' RIGHT size 90

oCol:SetProgBar( oRsProj:Fields("End_Date"):Value - oRsProj:Fields("Start_date"):Value, oRsProj:Fields("End_Date"):Value - date(), oBrw:bClrStd )
 
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Inserting a progress bar with xBrowse

Postby Rick Lipkin » Tue Aug 07, 2012 1:24 pm

Reinaldo,André

This code now appears to be working to the point where I can see a progress bar based on the numeric value of the cell... I still have no clue why this works or how it paints :?

Thanks for your Help !

Rick Lipkin

Code: Select all  Expand view

ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Percent' size 90

        WITH OBJECT oBrw:Percent
            :nTotal          := 0
            :lTotal          := .t.
            :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
            :nDataStrAlign := AL_RIGHT
        END
 


Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Inserting a progress bar with xBrowse

Postby ADutheil » Tue Aug 07, 2012 1:43 pm

My sample is wrong. I think now I understood how it works. SetProgBar( Param1, Param2, Param3 )

Param1 is the maximum possible value of the data in the cell. In your case end date - begin date, the data of the cell should be the quantity of elapsed days from begin day.
Param2 is the width you want your column to be shown.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Inserting a progress bar with xBrowse

Postby Rick Lipkin » Tue Aug 07, 2012 2:42 pm

André

YES .. you are correct. Apparently the first parameter is the Max value ( 100 % ) and the second is the width of the column and the value of the column is evaluated as a percentage of the max ( 100 ).

Code: Select all  Expand view

ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Progress' size 90

        WITH OBJECT oBrw:Progress
          *  :nTotal          := 0
          *  :lTotal          := .t.
            :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
            :nDataStrAlign := AL_CENTER
        END

 


Also .. :nTotal and :lTotal are not needed ..

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 96 guests