How to display a progress bar in the status bar in Visual FoxPro 9.0 and earlier versions (259296)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q259296

SUMMARY

This article illustrates how to create a progress bar to display in a status bar when a SELECT-SQL query is performed in Microsoft Visual FoxPro 9.0 and earlier versions.

MORE INFORMATION

Sample Code

  1. Create a program (.prg) file in Visual FoxPro.
  2. Put the following code into the .prg file:
    SET STATUS BAR ON
    PUBLIC obar
    **Open table
    cTable = GETFILE("dbf")
    IF EMPTY(cTable)
       RETURN .T.
    ENDIF   
    
    **Create the Progress bar object
    obar = CREATEOBJECT("POnStatus")
    obar.pIndicatorStyle = "||"
    SELECT * FROM (cTable) WHERE obar.DrawStatus(RECNO(), RECCOUNT())
    SET MESSAGE TO
    CLOSE ALL
    RELEASE ALL
    
    ** Class definition for the Progress bar object
    DEFINE CLASS POnStatus AS Custom
        pIndicatorStyle = ""
         
        PROCEDURE DrawStatus
        LPARAMETER nRecno, nReccount
        LOCAL nPtr, cIndicator
        
            nPtr = INT(nRecno*100/nReccount)
            cIndicator = REPLICATE(THIS.pIndicatorStyle, nPtr) + ;
               SPACE(2) + STR(nPtr)+"%"
            SET MESSAGE TO LEFT(cIndicator, LEN(cIndicator))
            RETURN .T.
        ENDPROC
    
    ENDDEFINE     
    
    					
  3. Save and run the .prg file.
  4. When prompted with the Open dialog box, select a table such as the Customer table in the Samples directory. While the query runs, you can see the progress bar updating in the status bar.

REFERENCES

For additional information on creating a thermometer bar, click the article number below to view the article in the Microsoft Knowledge Base:

139388 How To Create a Thermometer Bar in Visual FoxPro


Modification Type:MajorLast Reviewed:3/17/2005
Keywords:kbCodeSnippet kbDatabase kbhowto kbSQLProg KB259296